You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ugo Cei <ug...@apache.org> on 2005/06/27 15:59:24 UTC

[CForms] Repeater with links

Here's a simple problem for which I cannot seem to find a simple 
solution (or any solution at all). I hope someone here can help me.

I have a Collection of Java beans. Each bean has a couple of 
properties: "id" (Integer) and "name" (String).

I also have a form with a repeater:

     <fd:repeater id="current">
       <fd:widgets>
         <fd:output name="id" id="id">
           <fd:datatype base="integer"/>
         </fd:output>
         <fd:output id="name">
           <fd:label>Name</fd:label>
           <fd:datatype base="string"/>
         </fd:output>
         <fd:booleanfield id="select">
           <fd:label>Select</fd:label>
         </fd:booleanfield>
       </fd:widgets>
     </fd:repeater>

The repeater is bound to the collection:

   <fb:repeater id="current" parent-path="." row-path="current">
     <fb:identity>
       <fb:value id="id" path="@id" direction="load"/>
     </fb:identity>
     <fb:on-bind>
       <fb:value id="name" path="name" direction="load"/>
     </fb:on-bind>
   </fb:repeater>

As you can see, data is mostly read-only. I am just interested in the 
value of the "select" field for selecting some rows to be further 
processed.

I also created a template for displaying the repeater as a two-column 
table. Column 1 is for the "select" widget, whereas column 2 shoud 
display the "name" property. That was easy.

The next requirement is for each "name" to be a link to an URL which 
depends on the value of the corresponding "id". Something like:

     <ft:repeater-widget id="current">
       <tr>
         <td><ft:widget id="select"/></td>
         <td>
           <a href="/base/[INSERT-ID-HERE]"><ft:widget id="name"/></a>
         </td>
       </tr>
     </ft:repeater-widget>

Now the question is: what would be the easiest way to put the "id" 
property of the bean bound to the current row in place of the 
"[INSERT-ID-HERE]" string?

	Thanks in Advance,

		Ugo

-- 
Ugo Cei
Tech Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Wine & Food Blog: http://www.divinocibo.it/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [CForms] Repeater with links

Posted by Mark Lundquist <ml...@comcast.net>.
On 2005-06-27 07:09:24 -0700, Reinhard Poetz <re...@apache.org> said:

>> Now the question is: what would be the easiest way to put the "id" 
>> property of the bean bound to the current row in place of the 
>> "[INSERT-ID-HERE]" string?
> 
> You have to use the cforms macro library to get the id:
> 
> ...
> <jx:import uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
> ...
> 
> <ft:repeater-widget id="current">
>    <tr>
>      <td><ft:widget id="select"/></td>
>      <td>
>        <a 
> href="/base/${repeater.getRow(repeaterLoop.index).lookupWidget('id').value">
 
> 
>       <ft:widget id="name"/></a>
>      </td>
>    </tr>
> </ft:repeater-widget>

That rocks.  I've always used an XSLT transform to solve this problem, 
now I don't have to!

Thanks Reinhard,
—ml—

PS looks like a shorter way to write it is

	<a href="/base/${context_widget_.lookupWidget('id').value">




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [CForms] Repeater with links

Posted by Ugo Cei <ug...@apache.org>.
Il giorno 28/giu/05, alle 09:15, Reinhard Poetz ha scritto:

> jx-macro is even more advanced than the FormsTransformer (Ajax, tree  
> widget) but might have performance problems (I haven't tested it)  
> caused by jx:set. This problem was eliminated in trunk  
> (http://marc.theaimsgroup.com/?l=xml-cocoon- 
> cvs&m=111641612705437&w=2). As I don't use jx-macro with a 2.1  
> installation  my itch to solve the problem in 2.1 wasn't strong  
> enough.
>
> According to _my measurments_, in trunk the FormsTransformer is only  
> about 0 - 4 % faster than jx-macro which isn't a reason to use the  
> transformer because of its better performance any more.

I am using 2.1.8-dev but I hope this performance problem isn't going to  
be a big issue, since my form is quite simple, even though the repeater  
might have tens (or even hundreds) of rows. I might try to limit that  
number if I run into performance issues.

Anyway, thanks for your tip, it was invaluable!

	Ugo

-- 
Ugo Cei
Tech Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Wine & Food Blog: http://www.divinocibo.it/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [CForms] Repeater with links

Posted by Reinhard Poetz <re...@apache.org>.
Ugo Cei wrote:
> Il giorno 27/giu/05, alle 16:09, Reinhard Poetz ha scritto:
> 
>> You have to use the cforms macro library to get the id:
>>
>> ...
>> <jx:import 
>> uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
>> ...
> 
> 
> In this case, I should not be using the FormsTransformer, right? Are 
> there any limitations/caveats with the macros WRT the FormsTransformer?

jx-macro is even more advanced than the FormsTransformer (Ajax, tree widget) but 
might have performance problems (I haven't tested it) caused by jx:set. This 
problem was eliminated in trunk 
(http://marc.theaimsgroup.com/?l=xml-cocoon-cvs&m=111641612705437&w=2). As I 
don't use jx-macro with a 2.1 installation  my itch to solve the problem in 2.1 
wasn't strong enough.

According to _my measurments_, in trunk the FormsTransformer is only about 0 - 4 
% faster than jx-macro which isn't a reason to use the transformer because of 
its better performance any more.

-- 
Reinhard Pötz           Independent Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [CForms] Repeater with links

Posted by Ugo Cei <u....@pronetics.it>.
Il giorno 27/giu/05, alle 16:09, Reinhard Poetz ha scritto:

> You have to use the cforms macro library to get the id:
>
> ...
> <jx:import 
> uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
> ...

In this case, I should not be using the FormsTransformer, right? Are 
there any limitations/caveats with the macros WRT the FormsTransformer?

	Ugo

-- 
Ugo Cei
Tech Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Wine & Food Blog: http://www.divinocibo.it/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [CForms] Repeater with links

Posted by Reinhard Poetz <re...@apache.org>.
Ugo Cei wrote:
> Here's a simple problem for which I cannot seem to find a simple 
> solution (or any solution at all). I hope someone here can help me.
> 
> I have a Collection of Java beans. Each bean has a couple of properties: 
> "id" (Integer) and "name" (String).
> 
> I also have a form with a repeater:
> 
>     <fd:repeater id="current">
>       <fd:widgets>
>         <fd:output name="id" id="id">
>           <fd:datatype base="integer"/>
>         </fd:output>
>         <fd:output id="name">
>           <fd:label>Name</fd:label>
>           <fd:datatype base="string"/>
>         </fd:output>
>         <fd:booleanfield id="select">
>           <fd:label>Select</fd:label>
>         </fd:booleanfield>
>       </fd:widgets>
>     </fd:repeater>
> 
> The repeater is bound to the collection:
> 
>   <fb:repeater id="current" parent-path="." row-path="current">
>     <fb:identity>
>       <fb:value id="id" path="@id" direction="load"/>
>     </fb:identity>
>     <fb:on-bind>
>       <fb:value id="name" path="name" direction="load"/>
>     </fb:on-bind>
>   </fb:repeater>
> 
> As you can see, data is mostly read-only. I am just interested in the 
> value of the "select" field for selecting some rows to be further 
> processed.
> 
> I also created a template for displaying the repeater as a two-column 
> table. Column 1 is for the "select" widget, whereas column 2 shoud 
> display the "name" property. That was easy.
> 
> The next requirement is for each "name" to be a link to an URL which 
> depends on the value of the corresponding "id". Something like:
> 
>     <ft:repeater-widget id="current">
>       <tr>
>         <td><ft:widget id="select"/></td>
>         <td>
>           <a href="/base/[INSERT-ID-HERE]"><ft:widget id="name"/></a>
>         </td>
>       </tr>
>     </ft:repeater-widget>
> 
> Now the question is: what would be the easiest way to put the "id" 
> property of the bean bound to the current row in place of the 
> "[INSERT-ID-HERE]" string?

You have to use the cforms macro library to get the id:

...
<jx:import uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
...

<ft:repeater-widget id="current">
   <tr>
     <td><ft:widget id="select"/></td>
     <td>
       <a 
href="/base/${repeater.getRow(repeaterLoop.index).lookupWidget('id').value">
       <ft:widget id="name"/></a>
     </td>
   </tr>
</ft:repeater-widget>

-- 
Reinhard Pötz           Independent Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org