Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fieldValue not working after upgrade to Struts 2.0.11

 
Swathi Ram
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using displaytags to display a table of users.
Each user can be selected using a checkbox(I was passing the userid to the action class), and the following code was used.

<display:table name="people" requestURI="" pagesize="${row}" sort="list" id="jobResults" class="candSearchResults" >
<display:column><s:checkbox theme="simple" name="checked" fieldValue="${jobResults.userId}" /></display:column>
<display:column property="preferedName" title="Name" sort="true" /><display:column property="userName" title="Username (e-mail)" sort="true" maxLength="10"/>
</display:table>

Everything was working fine, until I upgraded to Struts 2.0.11
Now I get the following error and the page blows up

SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /secure/hiring-center/admin/manage-users.jsp(29,22) According to TLD or attribute directive in tag file, attribute value does not accept any expressions.

Anyone having any input on this please help.
Thanks in advance.
 
Swathi Ram
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any alternate way instead of using the JSP EL tags, as Struts 2.0.11 does not support this?
I need to be able to values from the JSP to the action class.(for eg: checkboxes, links etc)
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only reason for using struts-el tags was to be able to use EL expressions in the tag attributes. Since Struts2 requires a JSP 2.0 compliant web application, and since in JSP 2.0 EL expressions can be used anywhere in the JSP, struts-el tags are no longer needed.
 
Swathi Ram
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, but then if I don't use the EL tags then how will I pass the value in the above code?
How will the syntax be?

Thanks again.
 
Joachim Rohde
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the documentation: "Struts 2.0.10 corrected a serious security flaw in the Struts 2 tags where using JSP EL expressions could allow malicious OGNL expressions through. All users are encouraged to upgrade to Struts 2.0.11. Note that existing pages that utilize JSP EL expressions with Struts 2 tags will no longer work as of this release."

Just to understand, why it doesn't work anymore. You have to use OGNL now:
http://struts.apache.org/2.x/docs/ognl.html
 
Swathi Ram
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone tell me how I can pass a dynamic value to a checkbox while iterating and be able to access that value in the action class using struts 2.0.11?

Thanks
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the OGNL expression instead:
 
Swathi Ram
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fixed it.

<display:table name="people" requestURI="" pagesize="${row}" sort="list" id="jobResults" class="candSearchResults" >
<% String job = (String)((User)pageContext.getAttribute("jobResults")).getUserId() ;
request.setAttribute("jobResult", job); %>
<display:column><s:checkbox theme="simple" name="checked" fieldValue="%{#request.jobResult}"/> </display:column>


thanks for the inputs
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic