aspose file tools*
The moose likes Struts and the fly likes Struts2 UI - Change / Set UI component attributes dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 UI - Change / Set UI component attributes dynamically" Watch "Struts2 UI - Change / Set UI component attributes dynamically" New topic
Author

Struts2 UI - Change / Set UI component attributes dynamically

amol bakre
Greenhorn

Joined: May 21, 2001
Posts: 25
Hi,

Is it possible to change / set the attributes of struts2 UI component dynamically..As an example i will take the following example..

Suppose we have 10 text boxes on a page [<s:textarea>], out of which 5 are necessary and the rest are optional for a user to input data into.
So not to confuse the user i would want to just display 5 by default and give a button for example..lets say "More" which when clicked makes the other 5 visible on the form and the user can input data into these..
I tried to do exactly this but seems that there are problems with java script and the struts2 tags, opening a pop up window and asking the user to input to enter values in that window, take the values back to the parent form as hidden values seems a little cumbersome.

Can anybody let me know of how to achieve this kind of a functionality in Struts2 by changing the attributes, in our case for example disabled attribute or visible attribute (although, i think that this property is not available)..

Thanks a ton in advance..
Regards,
Am
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you need to add input elements dynamically why not just use JavaScript?

That aside, the "cssStyle" attribute lets you set styles.
amol bakre
Greenhorn

Joined: May 21, 2001
Posts: 25
Hi,

Oh, i am not much aware of the css etc, javascript did not seem to work properly with struts2, just used script tag directly in the page and tried to refer to the elements but javascript does not recognize the struts2 elements, for example <s:textarea>.
I am not very good with css and javascript or jsp's, had only been writing servlets, ejb's, beans, now springs etc..
Can you help by maybe citing example..

Many thanks..
Regards,
Am
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You don't use custom tags when creating elements via JavaScript; you create them by hand.
amol bakre
Greenhorn

Joined: May 21, 2001
Posts: 25
hi,

mm..okay..

Thanks..
Am
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 UI - Change / Set UI component attributes dynamically