struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "oscar perez" <>
Subject Problem with OGNL syntax
Date Mon, 03 Mar 2008 21:59:42 GMT
I  am having a very strange problem with struts 2. I am newbie to Struts 2
so maybe it is a simple thing I misunderstood.
I have an abstract class (enterprise) and 4 subclasses. I want to perform
CRUD operations on them and since all the properties are common to all the
subclasses I've decided to use only one form and one action for all of them.
The problem is that I cannot use in the form the reference to the abstract
class Enterprise since when I create a new entry the bean instantiation
fails as Enterprise is an abstract class and I didnt want to create 4 forms
either so I came up with the following

In the form page to get the type of the company that I am editing and using
logic tags to create a variable holding the name of the proper instance..:

<s:if test="typeCompany.equalsIgnoreCase('CUSTOMER')">
<s:set name="companyType" value="%{'customer'}/>

and then I try to use the proper name in the form tags like that:

<s:textfield name="%{companyType}.name" value="%{%{companyType}.name}"/>

and this shows nothing as value
If instead I use the following

<s:textfield name="%{companyType}.name" value="%{}"/>
I get the string as value
But now if I use the key field like this:
<s:textfield key="%{}" name="%{companyType}.name" />

Then it works just fine, It renders the value that holds. I
would like to use value rather than key because I don't want to create more
resource bundles for localization since suits to the 4

I hope I managed to explain my issue clearly. Any help is highly
Thank you!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message