Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display:table tag in Struts Application

 
deep kulkarni
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am designing Struts application and in JSP i have used <html:form>tag and for form data i used <display:table > tag. Now data is showing properly but when i am editing form data and submitting to action that time i am unable to get submitted form data instead i m getting old form which was set in session . Following is code for ref.

<html:form name="fmCustomerMaster" type="com.algo.struts.form.CustomerForm" action="/CustomerAction.do" method="post">
<display:table id="customerList" name="sessionScope.CustomerForm.customerList" pagesize="10" >
<display:column title="<input type='checkbox' name='selectall' onclick=\"selectAll(0,'chkEdit',UpdateRow, this.checked, 7)\" />">
<input type="checkbox" name="chkEdit"
value='<bean:write name="customerList" property="customerCode"/>'>
</display:column>
<display:column title="Customer Code" sortable="true">
<html:text name="customerList" property="customerCode"></html:text>
</display:column>
</display:table>
</html:form>
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
deep kulkarni wrote:Hi,
Now data is showing properly but when i am editing form data and submitting to action that time i am unable to get submitted form data instead i m getting old form which was set in session .

Why are you setting data in session, you can any time populate/store data in request scope, that will solve your problem.
 
deep kulkarni
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to struts application and display:table tag also. Can you please elaborate more on request Scope .Because i have tried following
<display:table id="customerList" name="requestScope.CustomerForm.customerList" pagesize="10" >
that time its not get data to display (in action class i have populate list and list is form property )
when i am setting this form in session and using following
<display:table id="customerList" name="sessionScope.CustomerForm.customerList" pagesize="10" >
that time it is displaying list data properly.Because i am populating list and setting form in session in action class .
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
deep kulkarni wrote: ... setting form in session in action class .

So what modification you will need to set list in "request" scope ? Its a very basic JSP/Servlets fundas
 
deep kulkarni
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You are correct sir, i tried as you have suggested but in struts application for action we get form as

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
CustomerForm customerForm = (CustomerForm) form;

here i am not getting form with modified values.

let me make it more clear as i had given JSP code before i am giving action code as below,
//

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
CustomerForm customerForm = (CustomerForm) form;

CustomerBean customerBean = new CustomerBean();

ArrayList cusDetailList = new ArrayList();
cusDetailList.add(new CustomerBean("CODE1","ABC","PUNE","C1",1,"ABCD"));
cusDetailList.add(new CustomerBean("CODE2","ABC1","PUNE1","C11",2,"ABCD1"));
customerForm.setCustomerList(cusDetailList);

request.setAttribute("CustomerForm", customerForm);
//request.getSession().setAttribute("CustomerForm", customerForm);
return mapping.findForward("success");
}
//
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I'll make it simple, remove your Action Form (CustomerForm) class from "session" scope. like, edit the struts-config.xml entry for CustomerAction

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64608
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
James Gadbury
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sagar Rohankar wrote:OK, I'll make it simple, remove your Action Form (CustomerForm) class from "session" scope. like, edit the struts-config.xml entry for CustomerAction



I am learning Struts 2 and I am interested to learn about the original poster's problem and solution. Are the path and scope attributes of the action tag (as in your example) now deprecated in struts 2? I ask as I added the attributes to one of my action mappings and both path and scope were not recognised.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts 2 is a *completely* different framework than Struts 1; essentially nothing from S1 config files will work in an S2 config.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic