• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 UI - Change / Set UI component attributes dynamically

 
amol bakre
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't use custom tags when creating elements via JavaScript; you create them by hand.
 
amol bakre
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

mm..okay..

Thanks..
Am
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic