Link to home
Start Free TrialLog in
Avatar of lensi
lensi

asked on

Using sTRUTS lOGIC ItERATOR TAG

HI Guys

need an idea or suggestion..

say i have a class Employee which has its own get and set methods
and i have a class Role which has its own get and set methods
and i have a joining class Employee_Role which has Employee object and Role object and get and set methods for it..

Well i have a vector (as collection object)

for loop
{
      vector.add(employee);
      vector.add(role);
      vector.add(employee_role);
}

since i need to display list of employees with their role names....
like BELOW..
Employee id ------- Employee name ---- Employee role name

Now i want to use iterator .. i have vector in the same class with scope as "request"..

request.setAttribute("employee_role",employee_roles_vector); // From bean iam getting vector..Vice versa i can do there in bean itself....
---SOME CODE-------
-----SOME CODE-----
------SOME CODE----
<logic:iterate id="emp_role" property="employee_role" scope="request" type="supportingClasses.GetEmployees">
      <html:text name="emp_role" property="mg_employee.id"/>
</logic:iterate>
but iam getting org.apache.jasper.JasperException: Null attribute name
but i dont have any field as name..since employee has first_name and role has role_name..

Well anyway i want to figure out my understanding on Iterator first....

I mean if i have a collection of objects in an iterator where each object is its own type and to retrieve the object properties we simply need to iteate the  collection object ...

if my understanding is right then is my code rght ???????????..
or the way iam doing is wrong... ?????????????????

Since iam a new bee iam trying to learn ..anyone's suggestion or advice would help me better...


Cheers
lenin
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lensi
lensi

ASKER

dude it worked out...

Cheers
lenin
Cool :-)

Good luck with it :-)

Tim