struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Konstadinis Euaggelos" <Vangelis.Konstanti...@eurodyn.com>
Subject Re: How do struts manage this
Date Fri, 04 Jul 2003 15:32:23 GMT
If you have the source code you will find somewhere  there is a class
EmployeBean, EmployeeLocalHome, EmployeeLocal smt like that.
The EmployBean class is mapped to employee table in your DB, so it has
set/get for all the properties of your table.

Collection employees = home.findAll();

This method gets all the employess(Object Emploeyees, LocalInterface/
LocalHomeInterface for the EJB Object  ) from the database.
Your ejb-guru must know this,

The object Employee which is LocalInterface/ LocalHomeInterface is provided
to client to do any data manipulation , this object has all the information
of the table, it has set/get method  for the properties of your table,


Ask your EJB  guru  when you create an ENTITY BEAN, which interfaces do you
get and what methods has each interface.


Hope this helps.

Vangos.





----- Original Message -----
From: "Peter Bosmans" <peter.bosmans@ad.khlim.be>
To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
Sent: Friday, July 04, 2003 6:07 PM
Subject: Re: How do struts manage this


> First, thanks for the second reply, because we changed our mail-server
> and misconfigured it. So we lost a lot of mails.
>
> After reading and debugging for a while. I still don't understand it.
> If  a dump the contents of the collection employees to stdout i see
> "Employee:1, Employee:2, Employee:5, ..., Employee:8909" (the numbers
> are the emp_id).
>
> I also looked into the employees object with a debugger just after
'session.setAttribute("employees", employees);' into source of the struts
action code. It gives me tesame result.
>
> I see nothing of the other properties. And still it works good. I see
> all my properties in my result web-page.
>
> What do you mean about LocalObject ?
>
> I've asked this question  to  our  EJB  guru , but he can't help me. So
> it's still black magic to me.
> Please help.
>
> Peter
>
> Konstadinis Euaggelos wrote:
>
> >I have already reply once...
> >
> >Collection employees = home.findAll();
> >
> >
> >This code returns a collection with Employes, LocalObject (you must read
> >about ejbs, there are a lot of books for this.)
> >The collection employees is not  filled with emp_id but with
EmployeeObject,
> >
> >This object has all the properties of the Employee table(employeeid,
> >firstname, lastname, ....)
> >That the code below is OK, because the Object in the iterator has all
this
> >properties.
> >
> >
> ><logic:present name="employees" scope="session">
> >     <logic:iterate id="currentEmployee" name="employees"
scope="session">
> >      <tr>
> >       <td>
> >        <bean:write name="currentEmployee" property="employeeid"/>
> >       </td>
> >       <td>
> >        <bean:write name="currentEmployee" property="firstname"/>
> >       </td>
> >       <td>
> >        <bean:write name="currentEmployee" property="lastname"/>
> >       </td>
> >       <td>
> >        <bean:write name="currentEmployee" property="extension"/>
> >       </td>
> >       <td>
> >        <bean:write name="currentEmployee" property="department"/>
> >       </td>
> >       <td>
> >        <bean:write name="currentEmployee" property="city"/>
> >
> >
> >
> >If you have any question please  ask..
> >
> >
> >----- Original Message -----
> >From: "Peter Bosmans" <peter.bosmans@relay.khlim.be>
> >To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
> >Sent: Friday, July 04, 2003 12:19 PM
> >Subject: How do struts manage this
> >
> >
> >
> >
> >>I'm playing with a demo running with struts, jboss and a mysql database.
> >>This example extracts data from a database and dump this in a table on
> >>my browser.
> >>But i don't understand one thing.
> >>In the action method they set an attribute "employees" with the
> >>collection employees. Which is filled only with the emp_id numbers (see
> >>employee EJB). In struts-config.xml is "employeeviewsucces" forwarded to
> >>"employeeviewsucces.jsp".
> >>In employeeviewsucces.jsp they refer to this "employees". How can get
> >>these logic:iterate the other data from the database. (During debuging i
> >>found out that the EJB methods were called, but i don't understand who
> >>and why these methods are called. I see no link between the EJBmethods
> >>and the jsp calls.
> >>Can somebody give me e little bit more explanation please or a hint
> >>where i can find more explanation about this.
> >>Thanks in advance.
> >>Peter
> >>
> >>Here a snip of  the struts action-code :
> >>.....
> >>   try {
> >>     InitialContext jndiContext = new InitialContext(env);
> >>     Object ref = jndiContext.lookup("Employee");
> >>     EmployeeHome home=
> >>(EmployeeHome)PortableRemoteObject.narrow(ref,EmployeeHome.class);
> >>     Collection employees = home.findAll();
> >>     session.setAttribute("employees", employees);
> >>     } catch (Exception e) {
> >>     return (mapping.findForward("employeeviewfailure"));
> >>   }
> >>   return (mapping.findForward("employeeviewsuccess"));
> >>}
> >>.....
> >>
> >>Here's a the findall method of the Employee EJB
> >>.....
> >>public Collection ejbFindAll() {
> >>   Vector employeeKeys = new Vector();
> >>   String sqlString = "select EMP_ID from EMPLOYEE";
> >>   try {
> >>     Statement s = connection.createStatement();
> >>     ResultSet rs = s.executeQuery(sqlString);
> >>     while (rs.next()) {
> >>       employeeKeys.addElement(new Integer(rs.getInt("EMP_ID")));
> >>     }
> >>    rs.close();
> >>   } catch (SQLException e) {
> >>     System.out.println("An SQL Exception occurred while querying result
> >>set of employee");
> >>   }
> >>   return employeeKeys;
> >>}
> >>.....
> >>
> >>employeeviewsuccess if forwarded to employeeviewsucces.jsp. Here's the
> >>snip of the code i don't understand.
> >>.....
> >>   <logic:present name="employees" scope="session">
> >>    <logic:iterate id="currentEmployee" name="employees"
scope="session">
> >>     <tr>
> >>      <td>
> >>       <bean:write name="currentEmployee" property="employeeid"/>
> >>      </td>
> >>      <td>
> >>       <bean:write name="currentEmployee" property="firstname"/>
> >>      </td>
> >>      <td>
> >>       <bean:write name="currentEmployee" property="lastname"/>
> >>      </td>
> >>      <td>
> >>       <bean:write name="currentEmployee" property="extension"/>
> >>      </td>
> >>      <td>
> >>       <bean:write name="currentEmployee" property="department"/>
> >>      </td>
> >>      <td>
> >>       <bean:write name="currentEmployee" property="city"/>
> >>      </td>
> >>      <td>
> >>       <a href="employeedelete.do?id=<bean:write
> >>        name="currentEmployee" property="employeeid"/>">Delete</a>
> >>      </td>
> >>      <td>
> >>       <a href="employeemodifysetup.do?id=<bean:write
> >>        name="currentEmployee" property="employeeid"/>">Modify</a>
> >>      </td>
> >>     </tr>
> >>    </logic:iterate>
> >>   </logic:present>
> >>.....
> >>
> >>
> >>
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message