Solved

Using sTRUTS lOGIC ItERATOR TAG

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
I am having a difficulty creating a responsive Page for my website. 10 87
Java Script nested call 3 89
jsp login check 12 53
running on tomcat not jboss eap 7.0 3 32
This article discusses how to implement server side field validation and display customized error messages to the client.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 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