InfoQ Article: Migrating Struts Apps to Struts 2 - Part III
Read Migrating to Struts 2 - Part III
After reading this article series, you should understand the Struts2 architecture (both the overall and the user interface architecture); be able to explain the differences in request processing; understand how to configure a Struts2 application; and know how to combine actions and JSP’s.
JSTL Integration
by
Corby Page
Where the author suggests:
<tr>
<td align="right">Id:</td>
<td><s:property value="id" /></td>
</tr>
<s:textfield label="Title" name="title" value="%{title}"/>
I simply use the built-in JSTL Integration in Webwork 2 to write:
<tr>
<td align="right">Id:</td>
<td>${id}</td>
</tr>
<s:textfield label="Title" name="title" value="${title}"/>
This also relieves me of a dependency on OGNL.
Is the JSTL integration not supported in Struts 2, or is the author just using the cumbersome notation for illustrative purposes?
Re: JSTL Integration
by
Don Brown
Is the JSTL integration not supported in Struts 2, or is the author just using the cumbersome notation for illustrative purposes?
Struts 2 continues the same support WebWork 2 had for JSTL, as smooth JSP, JSTL, and JSF integration is a top priority.
Freemarker
by
Martin Gilday
Re: Freemarker
by
Ian Roughley
Re: JSTL Integration
by
Ian Roughley
The syntax being suggested here seems verbose, and requires the user to differentiate between request scope and value stack.
Not sure what you are specifically talking about. Using the property tag searches the value stack which includes the request (as a named object). There is an option to select the request directly, but it is not necessary.
Is the JSTL integration not supported in Struts 2, or is the author just using the cumbersome notation for illustrative purposes?
Don answered the first part. Regarding the second - I was illustrating the pure struts2 tag library example. There are many ways to mix and match techniques in struts2, my goal was to keep things simple for this article.
Re: JSTL Integration
by
Corby Page
Not sure what you are specifically talking about. Using the property tag searches the value stack which includes the request (as a named object).
Using the (briefer) JSTL notation I described above also searches the value stack which includes the request.
Re: JSTL Integration
by
Ian Roughley
If the article was presenting JSTL as the final view markup rather than the Struts2 tag libs, the JSTL could have then been simplified.
Re: JSTL Integration
by
Aliaksandr Kuchar
Struts has no concept of a Value Stack we would need to have it specified in the original JSPs.
As I know it has. F.e. all tags that have scope attribute have option don't specifiy it. If the scope attribute is not specified, then the tag will search for the bean in the scopes in the order of page, request, session, and application. Or this is not a Value Stack?
Re: JSTL Integration
by
Ian Roughley
Problem running example
by
sunil narvekar
1. When I edit a blog entry and click on "Update" button, I saw these error messages in the Tomcat log file:
"SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception catched: Error setting expression 'entry' with value '[Ljava.lang.String;@8eae04'"
SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception catched: Error setting expression 'title' with value '[Ljava.lang.String;@1531164'
2. When I click on the "Back to List" link I see these error message in tomcat log:
SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception catched: Error setting expression 'id' with value '[Ljava.lang.String;@6127da'
----------------------------------------
Did anyone else have this problem? I have used Struts1 but
new to Struts2.
Re: Problem running example
by
Kishore Periassamy
some doubts
by
K Sathya Narayanan
i have a jsp named "displayEmployeeRecords.jsp"
which should display the list of employee details like name , empid , salary
i have implemeted this in struts1.2.
i have implemented the action class and other xml files .
i have a Arraylist object which contains a list of EmployeeModel object
1)if Arraylist is empty then the action class should be called
to populate the ArrayList
else the ArrayList should be iterated to display its content
2)tell me how to display this using struts2.0
i have done this in struts 1.2 but i dont know how to call a Action class
in Struts1.2-> /EmployeeData.do -> will call the Action class
in Strut22.0->?
in struts 1.2 -> logic:iterate to iterate the ArrayList and display the data
in strut2.0->?
Re: Problem running example
by
Lukasz Lenart
Re: method invocation - contains
by
Stanislav Pozdnyakov
I have a list of reports and I'm using <s:iterator > to show it on the screen and it works fine. But I also have another list with "bad" reports, and while iterating over reports list I need to check if bad reports list contains current report.
Here is what I want to have():
<s:iterator value="reports">
<s:if test="badReports.contains(report)">// Can I write expression like this or something similar
It's bad report
</s:if>
<s:else>
Good report
</s:else>
</s:iterator>
Can you explain how I can solve this?
</s:iterator>
How to make local struts.properties
by
Willie Banks
How to migrate logic:equal, logic:present in Struts2
by
Prathima G
I am new to Struts2 and currently working on Struts1.x to Struts2 migration. I need to change logic:equal and logic:present tags in the Jsp. Here is the problem I am facing:
STConstants.java has some constants such as:
public static final string ALT_PBR = "fusion";
Customer.java is a POJO having the following fields with getters and setters:
firstname, lastname,addressline1,addressline2,city,state,postalCode
In NewCmpAction.java we have:
Customer cust = new Customer();
//code which sets all the fields in cust object
.
.
//cust object is placed in session
session.put(STConstants.ALT_PBR,cust);
In slsDetail.jsp, I want to check if "cust" objects exists in session, if it exists then if the value of city field in "cust" object is equal to "CA".
In Struts 1.x we used logic:equal and logic:present but in Struts2 we do not have logic:equal and logic:present and I assume we have to implement this logic using if tag. I tried various combination but it didnt work.
I know if I use #session.fusion.city I will get the city value which I can compare to "CA" but I want to get the value "fusion" by referring to STConstants.ALT_PBR in the jsp. How can I do that? For eg: #session.???.city where ??? = STConstants.ALT_PBR.
Please help.
Also, how can I check if session has "cust" object? or how can I check if it is not present in session.
Re: How to make local struts.properties
by
Prathima G
other technologies used with struts 2
by
Lalit Khera
Please reply soon on kheralalit@gmail.com
Educational Content
Large-Scale Continuous Testing in the Cloud
John Penix May 24, 2013
Managing Build Jobs for Continuous Delivery
Martin Peston May 24, 2013
Clojure in the Field
Stuart Halloway May 23, 2013




Hello stranger!
You need to Register an InfoQ account or Login to post comments. But there's so much more behind being registered.Get the most out of the InfoQ experience.
Tell us what you think