You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by yitzle <yi...@users.sourceforge.net> on 2007/06/05 19:53:28 UTC

[S2] Mixing JSP variables and strut properties

Before I begin, I apologize if I offend anyone by asking a question
that could easily be found in the Struts 2 documentation by searching
for the correct keywords, and, no, I did not read the entire Struts
documentation nor any other Struts textbook (though I did read and
appreciate a good chunk of the Starting Struts 2 book).

See code below (numbered with cat -n).
Lines 0,1 work well. Lines 4,7,8 don't work. For line 4, I also tried
%{}, <%= %>. For line 7/8 I tried device[i].
Can someone tell me the correct way to escape/access the JSP variables
inside a Struts tag, and a Struts property (from a getter) in JSP?

Thanks!

Code:
 0          PIN1: <s:property value="device[0].PIN"/>
 1          Total Count: <s:property value="deviceCount"/>
 2          <TABLE>
 3                  <%
 4                  for ( int i = 0; i < deviceCount; i++ ) {
 5                          %>
 6                          <TR>
 7                                          <TD><s:property
value="device[%{i}].PIN"/></TD>
 8                                          <TD><s:property
value="device[<%=i%>].version"/></TD>
 9                                  </TR>
10                          <%
11                  }
12                  %>
13          </TABLE>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] Mixing JSP variables and strut properties

Posted by yitzle <yi...@users.sourceforge.net>.
Thank you.
I got it to work (after playing with it for an hour. Stupid array
variables sometimes are singular and sometimes plural. I need to
decide on one or the other... An hour because I don't know my own
naming... )

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] Mixing JSP variables and strut properties

Posted by Musachy Barroso <mu...@gmail.com>.
PIN1: <s:property value="device[0].PIN"/>
          Total Count: <s:property value="deviceCount"/>
          <TABLE>
                  <s:iterator value="device">
                          <TR>
                                <TD>
                                     <s:property value="PIN"/>
                                </TD>
                               <TD>
                                     <s:property value="version"/></TD>
                               </TR>
                 </s:iterator>
         </TABLE>

some references:
iterator: http://struts.apache.org/2.x/docs/iterator.html
OGNL: http://struts.apache.org/2.x/docs/ognl.html

musachy

On 6/5/07, yitzle <yi...@users.sourceforge.net> wrote:
>
> Before I begin, I apologize if I offend anyone by asking a question
> that could easily be found in the Struts 2 documentation by searching
> for the correct keywords, and, no, I did not read the entire Struts
> documentation nor any other Struts textbook (though I did read and
> appreciate a good chunk of the Starting Struts 2 book).
>
> See code below (numbered with cat -n).
> Lines 0,1 work well. Lines 4,7,8 don't work. For line 4, I also tried
> %{}, <%= %>. For line 7/8 I tried device[i].
> Can someone tell me the correct way to escape/access the JSP variables
> inside a Struts tag, and a Struts property (from a getter) in JSP?
>
> Thanks!
>
> Code:
> 0          PIN1: <s:property value="device[0].PIN"/>
> 1          Total Count: <s:property value="deviceCount"/>
> 2          <TABLE>
> 3                  <%
> 4                  for ( int i = 0; i < deviceCount; i++ ) {
> 5                          %>
> 6                          <TR>
> 7                                          <TD><s:property
> value="device[%{i}].PIN"/></TD>
> 8                                          <TD><s:property
> value="device[<%=i%>].version"/></TD>
> 9                                  </TR>
> 10                          <%
> 11                  }
> 12                  %>
> 13          </TABLE>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd