This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Struts and the fly likes fieldValue not working after upgrade to Struts 2.0.11 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "fieldValue not working after upgrade to Struts 2.0.11" Watch "fieldValue not working after upgrade to Struts 2.0.11" New topic
Author

fieldValue not working after upgrade to Struts 2.0.11

Swathi Ram
Greenhorn

Joined: Sep 18, 2007
Posts: 27
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

Joined: Sep 18, 2007
Posts: 27
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

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
Swathi Ram
Greenhorn

Joined: Sep 18, 2007
Posts: 27
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

Joined: Nov 27, 2006
Posts: 423

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

Joined: Sep 18, 2007
Posts: 27
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

Joined: Feb 15, 2005
Posts: 4864
Use the OGNL expression instead:
Swathi Ram
Greenhorn

Joined: Sep 18, 2007
Posts: 27
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
 
Consider Paul's rocket mass heater.
 
subject: fieldValue not working after upgrade to Struts 2.0.11
 
Similar Threads
pagination problem + struts1.3
${} is not working in JSP page.
Problem with sorting using display tag
maintin checkbox stauts during paginatin(dispalytag)
DisplayTag Probelm.