| 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.
|
 |
 |
|
|
subject: Checkbox issue when theme is simple
|
|
|