You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jay Sheth <sh...@gmail.com> on 2005/08/16 17:26:03 UTC

accessing variables using logic:iterate

Hi,
Currently I have a action class which does
session.setAttribute("recurringTaskSummary",v_recurringTaskSummary),
where v_recurringTaskSummary is a vector of type
SpRecurringTaskSummary which has certain variables such as
EmployeeName, EmployeeRef etc.

I am using logic:iterate as follows:
<logic:iterate id = "rtSummary" name="recurringTaskSummary">
            <bean:write name="rtSummary"/>
</logic:iterate>

The output is name of objects. However I want to somehow access the
variables employeename, employeeref etc. How do I do that ?

Thanks,
Jay

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: accessing variables using logic:iterate

Posted by Jay Sheth <sh...@gmail.com>.
Thanks a lot. Got it. As you said, the naming conventions were
followed, but I made a typo in the property attribute.

Sorry for the trouble.

Jay

On 8/16/05, Dave Newton <ne...@pingsite.com> wrote:
> Jay Sheth wrote:
> 
> >HI,
> >When i do :
> ><logic:iterate id="rtSummary" name="recurringTaskSummary">
> >        <bean:write name="rtSummary" property="employeeName"/>
> ></logic:iterate>
> >
> >it says not getter for employeeName in bean rtsummary.
> >'recurringTaskSummary' is a vector and not a bean.
> >I tried using the attribute type="SpRecurringTaskSummary" but got the
> >same error.
> >
> >I think I am missing the big picture or something basic in logic:iterate.
> >
> >
> (1) The 'type' attribute expects a full classname, but that's probably
> not relevant here.
> (2) What he was saying was that the Vector's objects must follow
> JavaBean naming conventions.
> 
> Dave
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: accessing variables using logic:iterate

Posted by Dave Newton <ne...@pingsite.com>.
Jay Sheth wrote:

>HI,
>When i do :
><logic:iterate id="rtSummary" name="recurringTaskSummary">
>        <bean:write name="rtSummary" property="employeeName"/>
></logic:iterate>
>
>it says not getter for employeeName in bean rtsummary. 
>'recurringTaskSummary' is a vector and not a bean. 
>I tried using the attribute type="SpRecurringTaskSummary" but got the
>same error.
>
>I think I am missing the big picture or something basic in logic:iterate.
>  
>
(1) The 'type' attribute expects a full classname, but that's probably 
not relevant here.
(2) What he was saying was that the Vector's objects must follow 
JavaBean naming conventions.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: accessing variables using logic:iterate

Posted by Jay Sheth <sh...@gmail.com>.
HI,
When i do :
<logic:iterate id="rtSummary" name="recurringTaskSummary">
        <bean:write name="rtSummary" property="employeeName"/>
</logic:iterate>

it says not getter for employeeName in bean rtsummary. 
'recurringTaskSummary' is a vector and not a bean. 
I tried using the attribute type="SpRecurringTaskSummary" but got the
same error.

I think I am missing the big picture or something basic in logic:iterate.

Thanks,

Jay


On 8/16/05, Stéphane Zuckerman <st...@gmail.com> wrote:
> Hi Jay,
> > session.setAttribute("recurringTaskSummary",v_recurringTaskSummary),
> 
> > SpRecurringTaskSummary [...] has certain variables such as
> > EmployeeName, EmployeeRef etc.
> >
> > I am using logic:iterate as follows:
> > <logic:iterate id = "rtSummary" name="recurringTaskSummary">
> >             <bean:write name="rtSummary"/>
> > </logic:iterate>
> >
> > The output is name of objects. However I want to somehow access the
> > variables employeename, employeeref etc. How do I do that ?
> 
> Just do something like :
> 
> <logic:iterate id="rtSummary" name="recurringTaskSummary">
>        <bean:write name="rtSummary" property="employeeName"/>
> </logic:iterate>
> 
> Don't forget to use the bean naming conventions, though.
> 
> --
> Stéphane ZUCKERMAN
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


[OT] Re: accessing variables using logic:iterate

Posted by Dave Newton <ne...@pingsite.com>.
Stéphane Zuckerman wrote:

> What I really dislike with struts tags is that attributes don't always 
> mean the same thing from tag to tag, which is disturbing. I'm mainly 
> thinking of the "name" and "property", and ".*Name" attributes too.

Ah, I'm glad to hear I'm not the only one that is wogged by this.

*sigh*

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: accessing variables using logic:iterate

Posted by Stéphane Zuckerman <st...@gmail.com>.
Dave wrote :
> As a followup, you may want to consider switching to JSTL for 
> straight-forward tasks such as this: where functionality is duplicated 
> between the Struts tags and JSTL it's generally recommended to go the 
> JSTL route. It's a trivial switch to make, and can be done mechanically 
> in most cases.
I totally agree with this statement. In addition of being a way to get 
more "genericity" in the JSP, it is (IMO) quite more coherent. What I 
really dislike with struts tags is that attributes don't always mean the 
same thing from tag to tag, which is disturbing. I'm mainly thinking of 
the "name" and "property", and ".*Name" attributes too.

-- 
Stéphane ZUCKERMAN

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: accessing variables using logic:iterate

Posted by Dave Newton <ne...@pingsite.com>.
Stéphane Zuckerman wrote:

>> I am using logic:iterate as follows:
>> <logic:iterate id = "rtSummary" name="recurringTaskSummary">
>>             <bean:write name="rtSummary"/>
>> </logic:iterate>
>>
>> The output is name of objects. However I want to somehow access the
>> variables employeename, employeeref etc. How do I do that ?
>
> <logic:iterate id="rtSummary" name="recurringTaskSummary">
>     <bean:write name="rtSummary" property="employeeName"/>
> </logic:iterate>
>
> Don't forget to use the bean naming conventions, though.
>
As a followup, you may want to consider switching to JSTL for 
straight-forward tasks such as this: where functionality is duplicated 
between the Struts tags and JSTL it's generally recommended to go the 
JSTL route. It's a trivial switch to make, and can be done mechanically 
in most cases.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: accessing variables using logic:iterate

Posted by Stéphane Zuckerman <st...@gmail.com>.
Hi Jay,
> session.setAttribute("recurringTaskSummary",v_recurringTaskSummary),

> SpRecurringTaskSummary [...] has certain variables such as
> EmployeeName, EmployeeRef etc.
> 
> I am using logic:iterate as follows:
> <logic:iterate id = "rtSummary" name="recurringTaskSummary">
>             <bean:write name="rtSummary"/>
> </logic:iterate>
> 
> The output is name of objects. However I want to somehow access the
> variables employeename, employeeref etc. How do I do that ?

Just do something like :

<logic:iterate id="rtSummary" name="recurringTaskSummary">
	<bean:write name="rtSummary" property="employeeName"/>
</logic:iterate>

Don't forget to use the bean naming conventions, though.

-- 
Stéphane ZUCKERMAN

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org