• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Display:table tag in Struts Application

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
We're all out of roofs. But we still have tiny ads:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic