tags:

views:

16

answers:

1

Hi All,

I have a struts 2 select element to select the mumber of results to be diplayed per page. I set the selected value in a session variable. On the JSP page I want the user selected value to be preselected in the select element. If I hard cord the value it works like this

<s:select name="fetchSize" cssClass="textCopmanyPropValue" value="20" headerKey="" list="#{'10':'10 Results/Page', '15':'15 Results/Page', '20' : '20 Results/Page', '25':'25 Results/Page'}"/>`

But if I use value from session using the <s:property> tag it doesn't work

<s:select name="fetchSize" cssClass="textCopmanyPropValue" value="<s:property value='%{#session.fetchSize}'/>" headerKey="" list="#{'10':'10 Results/Page', '15':'15 Results/Page', '20' : '20 Results/Page', '25':'25 Results/Page'}"/>`

Please help how can I work this out. And secondly, It is always so confusing when it comes to using one struts 2 tag inside another. Can somebody provide the sysntax how to use one struts 2 tag inside another.

Thanks in advance.

A: 

Get help from standard taglibs:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
...
<c:set var="fetchSize"><s:property value='%{#session.fetchSize}'/></c:set>
<s:select name="fetchSize" 
          cssClass="textCopmanyPropValue" 
          value="${fetchSize}" 
          headerKey="" 
          list="#{'10':'10 Results/Page', '15':'15 Results/Page', '20' : '20 Results/Page', '25':'25 Results/Page'}"/>`

Not very elegant, but functional.

gpeche