The var: binding prefix is much more limited than prop:, and prop: is
more limited than T4's use of OGNL.  But it's all part of the grand
plan :-)

Building a more complex expression language is something that will
wait for a later release, as you can write code in your component to
perform these types of operations (and still get instant reloading).

On Jan 13, 2008 1:33 PM, Chris Lewis <[EMAIL PROTECTED]> wrote:
> This almost works. Using the way you suggested as is oddly emits a comma
> only after the last element. Unfortunately I can't, at least not that I
> know of, express a "less than" clause like so:
>
> <t:if test="var:index < ${post.tags.size()}">,</t:if>
>
> T5 doesnt allow '<' here. As far as creating my own goes, I'm wondering
> if you've looked at the source of the core Loop component. If not, take
> my word for it, it's scary. If I could just subclass it and override a
> render method to honor a new parameter, it would probably be easy. Alas
> the T5 black magic prohibits this. At this point I see 2 options:
>
> 1) Do as you suggested and create my own loop, which will take a good
> bit of focused time to first understand why the internal loop does
> things the way it does.
> 2) Create a component that loops through a list and outputs a delimited
> list of pagelinks. The nasty part of this is that's its done in rigid
> java code - but it works.
>
> Has no one else done this yet?
>
>
> Robert Zeigler wrote:
> > What you /might/ be able to do (to avoid the java code), is to use var
> > here... I haven't played with the var prefix yet, so this is a "try
> > and see" idea. :) But. Something like:
> > <t:loop source="strings" value="var:string" index="var:index">
> >   <t:if test="var:index">,</t:if>
> >   <a href="#" t:type="pagelink" page="nada"
> > context="var:string">${var:string}</a>
> > </t:loop>
> >
> > If that works, you could even write your own DelimittedLoop component
> > and not have to duplicate the logic elsewhere.
> >
> > Robert
> >
> > On Jan 12, 2008, at 1/125:06 PM , Chris Lewis wrote:
> >
> >> That would work of course, but I'd like to do something like this:
> >>
> >> <t:loop source="strings" value="var:string" index="prop:index"
> >> delimit=", ">
> >> <a href="#" t:type="pagelink" page="nada"
> >> context="var:string">${var:string}</a>
> >> </t:loop>
> >>
> >> And then each element would be separated by my delimiter without any
> >> extra java code.
> >>
> >> Robert Zeigler wrote:
> >>> How about testing the value of index?
> >>> Something like:
> >>>
> >>> .java:
> >>>
> >>> private int index;
> >>> public int getIndex() { return index; }
> >>> public void setIndex(int i) index = i; }
> >>> public boolean isFirst() { return index==0; }
> >>>
> >>> .tml:
> >>>
> >>> <t:loop source="strings" value="var:string" index="prop:index">
> >>>  <t:if test="prop:first" negate="true">
> >>>    ,
> >>>  </t:if>
> >>>  <a href="#" t:type="pagelink" page="nada"
> >>> context="var:string">${var:string}</a>
> >>> </t:loop>
> >>>
> >>> Robert
> >>>
> >>> On Jan 12, 2008, at 1/124:41 PM , Chris Lewis wrote:
> >>>
> >>>> Sorry, I missed the "check if first" part. How can you do such a
> >>>> check in Loop? The "If" can test, but what can you test in a Loop?
> >>>> nothing that I know of will tell you where in the iteration you are.
> >>>>
> >>>> chris
> >>>>
> >>>> Davor Hrg wrote:
> >>>>> just reverse where you write the ","
> >>>>> instead of checking if last and putting comma behind
> >>>>>
> >>>>> check if first and put comma in front
> >>>>>
> >>>>> Davor Hrg
> >>>>>
> >>>>> On Jan 12, 2008 11:04 PM, Chris Lewis <[EMAIL PROTECTED]>
> >>>>> wrote:
> >>>>>
> >>>>>> So this ticket has been implemented in svn:
> >>>>>> https://issues.apache.org/jira/browse/TAPESTRY-2028
> >>>>>>
> >>>>>> And now I need whitespace... so how can I get it back? Is there
> >>>>>> or isn't
> >>>>>> there a way to disable this? Im using loop to output links
> >>>>>> (pagelinks),
> >>>>>> and i have whitespace behind in the body so there is separation.
> >>>>>> Unfortunately, it's getting stripped. Is there a workaround?
> >>>>>>
> >>>>>> On a related note, is there a way to know if im on the last
> >>>>>> iteration of
> >>>>>> the loop, so i could for example, follow all but the last with a
> >>>>>> ","?
> >>>>>> This may be outside the scope of loop as currently implemented,
> >>>>>> but i
> >>>>>> can see it being useful.
> >>>>>>
> >>>>>> chris
> >>>>>>
> >>>>>> ---------------------------------------------------------------------
> >>>>>>
> >>>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>>>> For additional commands, e-mail: [EMAIL PROTECTED]
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>>> For additional commands, e-mail: [EMAIL PROTECTED]
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>> For additional commands, e-mail: [EMAIL PROTECTED]
> >>>
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to