Mark,

Thanks very much for your time.
I will try that now.

Regards,

Michael


----- Original Message -----
From: "Galbreath, Mark" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Tuesday, May 14, 2002 1:22 AM
Subject: RE: Getting a list from a session bean and displaying the data in a
jsp


> Michael,
>
> 1.  Your input form should not contain iterator - it is for input. You
need
> to define your <html:text> tags inside an <html:form action="/saveGBEntry"
> method="post"> and declare this bean and action in struts-config.xml like
>
> <form-bean  name="GBEntryForm"
>   <!--name of the bean-->
>   type="com.morelogs.guestbook.GBEntryForm" />
>
> <action-mappings>
>   <action path="/saveGBEntry"
>           type="com.morelogs.guestbook.action.SaveGBEntryAction"
>           name="GBEntryForm"
>           input="/welcome.jsp"
>           scope="session"
>           validate="true" >
>    <forward name="success" path="/displayGBEntries.jsp" />
> </action-mappings>
>
> 2.  When you submit welcome.jsp, it fires SaveGBAction and automatically
> sets the propertiies of GBentryForm (mainly in case the user needs to
return
> because of an error).  You can now access all the bean properties:
>
> GBEntryForm entryForm = (GBEntryForm) form;
>
> which you can use to save the data to the database.  After which, make
your
> call to your session EJB and set the gbEntry property in the form bean:
>
> entryForm.setGbEntry( entryList);
>
> When done, struts will forward the request to displayGBEntries.jsp, where
> you then iterate throught the list:
>
> <logic:iterate name="GBEntryForm"
>            id="gbEntry"
>            scope="session"
>      property="gbEntry"
>            type="com.morelogs.guestbook.interfaces.gbEntry">
>
>   <bean:write name="gbEntry" property="entry_subject" />
>   <bean:write name="gbEntry" property="entry_name" />
>   <bean:write name="gbEntry" property="entry_date" />
> </logic:iterate>
>
> Mark
>
> -----Original Message-----
> From: Michael Delamere [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 13, 2002 5:43 PM
>
> Here�s the call to my session bean:
>
> ========== CALL TO SESSION BEAN ==============================
>          // Get a naming context
>          InitialContext jndiContext = new InitialContext();
>
>          // Get a reference to a EntryBean
>          Object ref  = jndiContext.lookup("ejb/guestbook/gbEntries");
>
>          // Get a reference from this to the Bean's Home interface
>          gbEntriesHome home = (gbEntriesHome)
>             PortableRemoteObject.narrow (ref, gbEntriesHome.class);
>
>     ArrayList entryList = new ArrayList();
>
>     gbEntries entriesObj = home.create();
>     Object[] entries = entriesObj.getEntriesList();
>     for (int i = 0; i < entries.length; i++)
>     {
>      gbEntry entry = (gbEntry) entries[i];
>       entryList.add(entry);
>
>       // I get the results printed in my output screen so this works.
>       System.out.println (entry.getEntry_subject() + "\t" +
> entry.getEntry_text() + "\t" +
>          entry.getEntry_date() + "\t" + entry.getEntry_views());
>     }
>
>     request.setAttribute("entryList", entryList);
> ================================================================
>
> Here�s the change in my JSP file:
> ===============  JSP FILE ========================================
> <%@ page language="java" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> <%@ taglib uri="/WEB-INF/struts-form.tld" prefix="form" %>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> <%@ taglib uri="/WEB-INF/nested-tags.tld" prefix="nested" %>
>
> <logic:iterate name="entryList"
>            id="gbEntry"
>            scope="request"
>            type="com.morelogs.guestbook.interfaces.gbEntry">
>   <tr>
>     <td><html:text property="entry_subject" /></td>
>     <td><html:text property="entry_text" /></td>
>     <td><html:text property="entry_date" /></td>
>   </tr>
> </logic:iterate>
> ===============================================================
> Could you please have a look over this to see if I have missed something.
> I would really appreciate further help on this.
>
> Regards,
>
> Michael
>
>
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Monday, May 13, 2002 10:12 PM
> Subject: Re: Getting a list from a session bean and displaying the data in
a
> jsp
>
>
> >
> > In a non-nested context, you would do the following for a collection of
> > objects associated with the request object
> >
> > <logic:iterate name="entryList"
> >            id="entry"
> >            scope="request"
> >            type="com.xxx.xxx.xxx.Entry">
> >   <tr>
> >     <td><html:text property="entry_subject" /></td>
> >     <td><html:text property="entry_text" /></td>
> >     <td><html:text property="entry_date" /></td>
> >   </tr>
> > </logic:iterate>
> >
> >
> >
> >
> >
> > "Michael Delamere" <[EMAIL PROTECTED]> on 05/13/2002 01:00:42 PM
> >
> > Please respond to "Struts Users Mailing List"
> >       <[EMAIL PROTECTED]>
> >
> > To:   "'Struts Users Mailing List' \(E-mail\)"
> >       <[EMAIL PROTECTED]>
> > cc:
> > Subject:  Getting a list from a session bean and displaying the data in
a
> >       jsp
> >
> >
> > Hi,
> >
> > I�ve got a session bean which returns an Object[] array of entity beans.
> > In
> > my action file I get the array via a jndiContext.lookup.  That�s all no
> > problem and I can retreive my data out of the entity beans.
> >
> > However, I�m slightly stuck getting them over to my jsp file.  I�ve
tried
> >
> > request.setAttribute("entryList", entryList);
> >
> > and then outputing the data with:
> >
> > <nested:iterate property="entryList">
> >   <tr>
> >     <td><nested:text property="entry_subject" /></td>
> >     <td><nested:text property="entry_text" /></td>
> >     <td><nested:text property="entry_date" /></td>
> >   </tr>
> > </nested:iterate>
> >
> > Could someone give me an insight of how this is done.
> > I would be most grateful.
> >
> > Thanks,
> >
> > Michael
> >
> >
> > --
> > To unsubscribe, e-mail:   <
> > mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: <
> > mailto:[EMAIL PROTECTED]>
> >
> >
> >
> >
> >
> >
> > **********************************************************************
> > Please Note:
> > The information in this E-mail message, and any files transmitted
> > with it, is confidential and may be legally privileged.  It is
> > intended only for the use of the individual(s) named above.  If you
> > are the intended recipient, be aware that your use of any confidential
> > or personal information may be restricted by state and federal
> > privacy laws.  If you, the reader of this message, are not the
> > intended recipient, you are hereby notified that you should not
> > further disseminate, distribute, or forward this E-mail message.
> > If you have received this E-mail in error, please notify the sender
> > and delete the material from any computer.  Thank you.
> > **********************************************************************
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to