Solved

Using sTRUTS lOGIC ItERATOR TAG

Posted on 2006-06-21
3
1,847 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now