You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nagraj Rao <na...@sigmainfo.net> on 2006/12/14 14:07:54 UTC

Help for Struts2 with JSTL

Hi 

Needed some help on struts2 for getting the id of a list i have in my sessionScope (say StateList). This individual object in this list is State which has fields "id" and "name". I'm using the following code to get a checkbox rendered with its id being the id of the state

<s:checkbox name="stateCheck" id="%{ StateList.id }/>

In the final HTML page i get the code as id="". Please do help me figure out how should i get the id.

I've tried out the following with all the 3 : "$", "#", "%"
StateList.id
StateList.state.id
sessionScope.StateList.id 

Kindly help,



regards,
Nagraj

Re: Help for Struts2 with JSTL

Posted by Martin Gainty <mg...@hotmail.com>.
Hello Nagraj

If the variable is not on the ValueStack (an example of items stored in ValueStack would include the Action instance) then use the #
so assuming StateList.id is set in Session use

<s:checkbox name="stateCheck" id="#session.StateList.id"/>

Anyone else?
M
--------------------------------------------------------------------------- 
This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited.



Hi 

Needed some help on struts2 for getting the id of a list i have in my sessionScope (say StateList). This individual object in this list is State which has fields "id" and "name". I'm using the following code to get a checkbox rendered with its id being the id of the state

<s:checkbox name="stateCheck" id="%{ StateList.id }/>

In the final HTML page i get the code as id="". Please do help me figure out how should i get the id.

I've tried out the following with all the 3 : "$", "#", "%"
StateList.id
StateList.state.id
sessionScope.StateList.id 

Kindly help,



regards,
Nagraj