?
Solved

Using sTRUTS lOGIC ItERATOR TAG

Posted on 2006-06-21
3
Medium Priority
?
1,856 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The well known Cerber ransomware continues to spread this summer through spear phishing email campaigns targeting enterprises. Learn how it easily bypasses traditional defenses - and what you can do to protect your data.
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
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 …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

800 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