Solved

Using sTRUTS lOGIC ItERATOR TAG

Posted on 2006-06-21
3
1,854 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:lensi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 125 total points
ID: 16959191
Why are you adding all 3 to the vector?

Surely if EmployeeRole class has an employee object (with a getEmployee method) and a Role object (with a getRole method), then you just need to add EmployeeRole objects into the vector, and iterate through these?

<logic:iterate id="emp_role" property="employee_role" scope="request">
     <html:text name="emp_role" property="employee.id"/> in role <html:text name="emp_role" property="role.id"/>
</logic:iterate>
0
 
LVL 1

Author Comment

by:lensi
ID: 16959607
dude it worked out...

Cheers
lenin
0
 
LVL 35

Expert Comment

by:TimYates
ID: 16959745
Cool :-)

Good luck with it :-)

Tim
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
In this blog we highlight approaches to managed security as a service.  We also look into ConnectWise’s value in aiding MSPs’ security management and indicate why critical alerting is a necessary integration.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question