One way to do it with JSTL is to use jsp includes, then just include the "component" wherever you want to use it. Other than that, I think you have to make an component class and drop jstl for that component. Then you could just plug in that componenent with <c:out value="${myComponent.display}"/>

Travis

Doug Kirk wrote:

With Velocity, this is a simple matter of creating macros to do your work for you. I use macros to generate my <select>'s from a database. Further, you can either place your macros in the file being rendered, or in the velocity global macro file.

So, in the global macro file you define:

#macro names($list)
  #foreach ($p in $list)
    $p.name
  #end
#end

Then, in your page, you simply write:

$names($model.projects)

In the macro above, Velocity doesn't care what type 'p' is, as it treats it as an Object any way; it will introspect for an accessor for the 'name' property and render it to the output.

Cheers,
Doug


On Monday, October 6, 2003, at 07:50 AM, Taavi Tiirik wrote:



Hello,


This is not entirely maverick specific but I am trying to find a
solution to this in maverick environment hence the question.

I am currently using jstl as a view technology but if this can
be achieved with velocity and not with jstl then I am quite
ready to switch. Prefer to find a quick jstl solution though.

I would like to make my views more modular and reuse
common components as much as possible. For example
if I iterate over some sort of collection I would rather
include a component that knows how to render this
object instead of having similar rendering code in so
many places.

So instead of this:
<c:forEach items="${model.projects}" var="p">
    <c:out value="${p.name}"/>, etc.
</c:forEach>

I would like to have something like this: (does not work like this though)
<c:forEach items="${model.projects}" var="p">
<c:import url="/components/output-project.jsp">
<c:param name="project" value="${p}"/>
</c:import>
</c:forEach>


and something like this in output-project.jsp:
<c:out value="${param.project.name}"/>, etc.

This kind of approach works as far as I only pass simpe strings
but not with beans, etc. I need beans :)

So please tell me how do you do this?

best regards,
Taavi



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
[INVALID FOOTER]





------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf [INVALID FOOTER]

.




------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf [INVALID FOOTER]

Reply via email to