Issue Details (XML | Word | Printable)

Key: STR-1954
Type: Improvement Improvement
Status: Closed Closed
Resolution: Won't Fix
Priority: Minor Minor
Assignee: Struts Developers
Reporter: David Wong
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Struts 1

Possibility of allowing parameter(s) in struts tags property

Created: 28/Jan/04 07:29 AM   Updated: 04/Jul/07 05:29 AM
Return to search
Component/s: Tag Libraries
Affects Version/s: Nightly Build
Fix Version/s: None

Environment:
Operating System: All
Platform: All

Bugzilla Id: 26476


 Description  « Hide
I have been using struts for about 3 years and I have being always wish to be
able to access bean/form getter methods that takes parameters. This is
particularly useful when working on multi-lingual support project.

For example to display the name of a location one would use the following,

    <bean:write name="location" property="name" />

translate to calling the getName() method in the location bean.

Now, if location name have translation in many difference language the above
tag usage will not be able to display the location name in a particular
language.

However, if we could have the ability to supply a parameter to a method through
the tag we could pick which language to the name in. That is, the tag usage
would becomes
    
    <bean:write name="location" property="name" parameter="-347849847775344" />

and this is translated to calling the getName(String languageId) method ==>
getName("-347849847775344").

I am happy to build the extension to support the feature proposed if it have
not been built.

Cheers,

David

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Joe Germuska added a comment - 28/Jan/04 08:57 AM
Mapped property accessors support accessing any bean property which takes a single string as its
parameter. In your example, if the string argument is always literal, you would use this syntax:

    <bean:write name="location" property="name(-347849847775344)" />

If you need to dynamically assign the parameter value, you can construct the value for property in
the page and then use a RT-expr to pass it to the bean:write tag:

<bean:define id="prop">name(<bean:write name="paramValue" />)</bean:define>
<bean:write name="location" property="<%= prop %>" />

It may not be glamorous or tidy, but it works. Personally, I'd be hesitant to add the attribute you
propose to the bean:write tag since the number of attributes for the various struts tags is already
large, and the names are sometimes already not terribly clear.

Martin Cooper added a comment - 05/Feb/04 12:53 PM
What you are asking for is an <arbitraryClass:write> tag. The <bean> taglib is
focussed on JavaBeans and their properties. A method which takes a parameter
does not conform to the rules for JavaBean properties, and so is outside the
scope of this taglib.

Don Brown made changes - 23/Apr/06 04:46 AM
Field Original Value New Value
issue.field.bugzillaimportkey 26476 27245
Paul Benedict made changes - 04/Jul/07 05:29 AM
Status Resolved [ 5 ] Closed [ 6 ]