aspose file tools
The moose likes Struts and the fly likes Checkbox issue when theme is simple Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Checkbox issue when theme is simple" Watch "Checkbox issue when theme is simple" New topic
Author

Checkbox issue when theme is simple

Miguel Almeida
Greenhorn

Joined: Mar 12, 2010
Posts: 9
I have a checkbox defined as:



The action that goes to this page has an activeSubstance object without any properties defined the 1st time we visit it.

With a normal theme (say theme="xhtml"), the html generated is:



With a simple theme, however, we get:


Notice how the value="true" attribute disappeared!
This seems to happen when the activeSubstance (which is being injected with Spring) hasn't been defined (ie, the "create new" page). When we've populated an activeSubstance (ie, "edit existing") we have, as expected:



The current solution for using the checkbox with the simple theme is some javascript to add the value="true", like:



Is there any cleaner solution?
Richard Golebiowski
Ranch Hand

Joined: May 05, 2010
Posts: 213

Try setting the fieldValue attribute:
fieldValue="true"
Miguel Almeida
Greenhorn

Joined: Mar 12, 2010
Posts: 9
Richard Golebiowski wrote:Try setting the fieldValue attribute:
fieldValue="true"


I have also tried that, but it produced no change - quite odd, as I thought that attribute was precisely for this purpose.
Richard Golebiowski
Ranch Hand

Joined: May 05, 2010
Posts: 213

That is odd. I have never seen setting the fieldValue not work. I'll have to give it a try later today and see what happens.
Miguel Almeida
Greenhorn

Joined: Mar 12, 2010
Posts: 9
Richard Golebiowski wrote:That is odd. I have never seen setting the fieldValue not work. I'll have to give it a try later today and see what happens.


I have found the source of the problem, thanks to your help. It appears there was a jquery action removing all "value" attributes when displaying the form (which is invisible when the page loads).
The fieldValue was, in fact, being applied, but the jquery was removing it just before the form was shown!

Thanks for the help, Richard.
Richard Golebiowski
Ranch Hand

Joined: May 05, 2010
Posts: 213

Glad you found the solution. I had a feeling that it was something else interfering with Struts. It seems that when you have a strange problem like this that it's caused by something else and not Struts.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Checkbox issue when theme is simple
 
Similar Threads
Check All button for all spring check boxes array
Function to select all
Need Help with binding click events to table rows
Problems with checkbox
jQuery: how to determine if any checkbox is checked.