jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <li...@ehatchersolutions.com>
Subject Re: TEI attributes differ depending on parent tag
Date Fri, 23 Nov 2001 12:49:19 GMT
> I think it would work if I did not need the TEI class.  I already use a
> getParent().getResults() method that returns a Collection to iterate
> through.  I was under the impression that the TEI class is necessary to
> allow the JSP to access the beans as the resultsTag iterates, so I can do
a
> <%=bean.getName()%> or similar.



> I have ordered Geary's book but before it
> arrives could you give me a hand?

I'll try....

> In the results tag, I retrieve the Collection from the parent tag and then
> for each bean in the collection I do
>
> context.setAttribute( alias, iterator.next(), PageContext.PAGE_SCOPE );
> return EVAL_BODY_TAG;
>
> where alias is the name I want to give the bean e.g. if alias =
"myprofile"
> then JSP can do <%=myprofile.getName()%>.
>
> If I remove the TEI class reference from the .tld I receive the following
> error through JSP
>
> *** Error: "myprofile" is either a misplaced package name or a
non-existent
> entity.

Actually, I'd recommend you have a look at Struts <bean:write> tag - it is
type agnostic and simply uses BeanUtils (from Jakarta Commons) to locate the
getters.  So in your case you could do this:

<tlib:profile keywords="abc def">
  <tlib:results>
     Found a profile called <bean:write name="Profile"
property="description/><br>
  </tlib:results>
</tlib:profile>

under the hood bean:write would call Profile.getDescription().

At the very least you could gain some taglib insight by studying the Struts
bean and logic tags.  If you're not already using Struts, looking at the
html and template (which Geary wrote) tags might be overkill.  Eventually
the Struts team will donate (I believe) the non-Struts-specific tags to the
Taglibs project - I think they are waiting for JSTL to be official (?).

    Erik

p.s. I referred to another great book just to look up more about TEI...
Manning's JSP Tag Librarys by Shachor, Chace, and Rydin.


--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message