File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Display:table tag in Struts Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Display:table tag in Struts Application" Watch "Display:table tag in Struts Application" New topic
Author

Display:table tag in Struts Application

deep kulkarni
Greenhorn

Joined: Dec 05, 2007
Posts: 18
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
deep kulkarni
Greenhorn

Joined: Dec 05, 2007
Posts: 18
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Dec 05, 2007
Posts: 18
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Jan 10, 2002
Posts: 61180
    
  66

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
James Gadbury
Greenhorn

Joined: Mar 20, 2009
Posts: 24
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

Joined: Sep 29, 2008
Posts: 12617

Struts 2 is a *completely* different framework than Struts 1; essentially nothing from S1 config files will work in an S2 config.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display:table tag in Struts Application