• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Couple of STRUTS questions

lozina

Lifer
I was hoping to get some help using struts...

firstly,

I want to be able to set a page variable within a nested logic tag and then test for that variable's value later. I cant figure out how to do this though...

as a pseduo code to get idea of what I am trying to do:

//some big nested logic tags
<s:set name="myVar" value="true"/>
// other code then closing the logic tags
<s:if test="%{myVar == 'true'}>
//do something
</s:if>

But I cannot figure out the correct syntax for this... If possible I'd rather not have to add a property to a bean but if that's the only way then so be it


secondly,

I have a page with a checkbox tied to a struts action form. But I want the checkbox to always show up as unchecked when the page loads, no matter what the value may be in the bean from last time. but it seems no matter what I do it always remembers the checkbox value if it was submitted with 'true' and then loads the page with it checked.

of course I could just hack the page by setting the property to false at the top of the page or just doing an onload javascript to say checked=false but is there a 'right' way to do this?
 
Is this struts1, or struts2? It looks like from your if tag you're using struts 2.

If that's the case, then it depends on where specifically the myVar lies within the value stack. If its set locally as you have demonstrated here, you should be able to use the if tag as:

edit: didn't show up quite how I wanted, the "attach code" seems to have some issues, but the syntax still looks correct. Just place each tag on a new line and it should work.
 
Back
Top