Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java Open Source > Struts
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Struts section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2007, 10:30 PM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying data in a struts form - Need help!

I have built an application very similar to the Employee example in the book. However, the data does not display in the JSP page.

My JSP page looks like this
Code:
<logic:iterate id="record" name="searchrecords">
              <tr>
                  <td width="95"><input name="submit" type="Badge Num" /> </td>
                <td width="115" class="style2"><bean:write name="record" property="ar_empno"/></td>


My strut-config looks like this
Code:
<action path="/searchList" 
            type="com.cta.acctTerm.web.action.SearchListAction"
            name="recordSearchFormBean"
            parameter="operation"
            scope="request">
              <forward name="back" path="/recordsearch.jsp"/>            
              <forward name="success" path="/searchList.jsp"/>
              <forward name="failure" path="/error.jsp"/>
        </action>
My Action looks like this
Code:
public ActionForward add(ActionMapping mapping, 
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
            modelFacade = new ModelDAOFacade();
            RecordSearchFormBean saveBean = (RecordSearchFormBean)form;
            String ar_empno = saveBean.getar_empno();

            ArrayList searchrecords = new ArrayList();//modelFacade.recordSearchLast(ar_last);
            AccountRecord record = new AccountRecord();
            record.setar_empno("9999");
            record.setar_first("TEST");
            searchrecords.add(record);

            request.setAttribute("searchrecords",  searchrecords);

            return(mapping.findForward("success"));
    }


However, my data does not display. I am sure the searchrecords data is being populated into the request.

Any ideas will be much appreciated.

On another note, is there a working version of the code that we can deploy as an example? I have tried for over a week to get this to work and am beginning to wonder if the book missed out on some information.

Thanks in advance for any information.

 
Old March 13th, 2007, 01:08 PM
Registered User
 
Join Date: Mar 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You just send me the jsp page so that i can
understand what method ur using to populate
data in jsp.

 
Old March 13th, 2007, 01:17 PM
Registered User
 
Join Date: Mar 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

in the action class method ur setting the values to some object like record, those values are not set to the form object
do one thing
1.create an attribute in the form class like
AccountRecord record = null;
create setter and getter method for it.
2. the record object in action class set to this setter method in the form , then u can populate the data in jsp page.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Prfessional Struts Applications - PrePopulate Form Mieber All Other Wrox Books 15 September 6th, 2007 01:36 AM
Form Bean in Struts meetravig Struts 0 July 19th, 2007 01:01 AM
displaying images in jsp using struts vijayalexander JSP Basics 0 November 6th, 2006 09:46 AM
check box default value in struts form sridevi Servlets 3 January 15th, 2006 11:13 PM
Submit repeated data item in a form using Struts somnathp Javascript How-To 0 July 26th, 2005 12:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.