alternate row in repeat with xforms:group doesn't works fine

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

alternate row in repeat with xforms:group doesn't works fine

julien-29

Hello,
I try with the last nightly build, but it doesn't work.
My example :
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr class="TABLEAUHEADERMINILISTE">
   <td >&#160;</td>
   <td >code</td>
 </tr>
 <xforms:repeat
nodeset="instance('main')/resultat/resultatRechTiers/listeTiers/tiers"
id='tier'>
    <xforms:group ref=".[ ( position() mod 2 ) = 0]">
      <tr class="TABLEAULGCLAIRE">
          <td>&#160;<input type="radio" name="radiobutton"
value="radiobutton"/></td>
          <td ><xforms:output ref="codeTiers"/></td>
       </tr>
     </xforms:group>
     <xforms:group ref=".[ ( position() mod 2 ) = 1 ]">
       <tr class="TABLEAULGFONCEE">
         <td>&#160;<input type="radio" name="radiobutton"
value="radiobutton"/></td>
         <td ><xforms:output ref="codeTiers"/></td>
       </tr>
    </xforms:group>
 </xforms:repeat>
 </table>

there is a problem because even there are not data (resultatRechTiers is empty)
, 2 rows empty are generated. (just the radio button are display)
I just want to alternate the row style.
Can you help me ?

thank you.


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: alternate row in repeat with xforms:group doesn't works fine

Erik Bruchez
Administrator
Julien,

The reason your example doesn't work is that position(), in XPath, is  
always evaluated within a certain context. As soon as you put square  
brackets ("[...]"), the context is changed, and position() always  
returns 1 in that case. So both your rows display.

I suggest you try the AVT approach which was proposed recently.

See this message:

http://www.nabble.com/Re%3A-Re%3A-is-there-any-example-of-styling-repeat-tables-p15860919.html

Also check out RESOURCES/apps/xforms-sandbox/samples/avt-zebra.xhtml  
in the latest builds.

-Erik

On Mar 7, 2008, at 5:16 AM, julien wrote:

>
> Hello,
> I try with the last nightly build, but it doesn't work.
> My example :
> <table width="100%" border="0" cellspacing="0" cellpadding="3">
>  <tr class="TABLEAUHEADERMINILISTE">
>   <td >&#160;</td>
>   <td >code</td>
> </tr>
> <xforms:repeat
> nodeset="instance('main')/resultat/resultatRechTiers/listeTiers/tiers"
> id='tier'>
>    <xforms:group ref=".[ ( position() mod 2 ) = 0]">
>      <tr class="TABLEAULGCLAIRE">
>  <td>&#160;<input type="radio" name="radiobutton"
> value="radiobutton"/></td>
>  <td ><xforms:output ref="codeTiers"/></td>
>       </tr>
>     </xforms:group>
>     <xforms:group ref=".[ ( position() mod 2 ) = 1 ]">
>       <tr class="TABLEAULGFONCEE">
> <td>&#160;<input type="radio" name="radiobutton"
> value="radiobutton"/></td>
> <td ><xforms:output ref="codeTiers"/></td>
>       </tr>
>    </xforms:group>
> </xforms:repeat>
> </table>
>
> there is a problem because even there are not data  
> (resultatRechTiers is empty)
> , 2 rows empty are generated. (just the radio button are display)
> I just want to alternate the row style.
> Can you help me ?
>
> thank you.
>
> --
> You receive this message as a subscriber of the [hidden email]  
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: alternate row in repeat with xforms:group doesn't works fine

Alessandro Vernet
Administrator
Julien,

On Fri, Mar 7, 2008 at 9:20 AM, Erik Bruchez <[hidden email]> wrote:
>  The reason your example doesn't work is that position(), in XPath, is
>  always evaluated within a certain context. As soon as you put square
>  brackets ("[...]"), the context is changed, and position() always
>  returns 1 in that case.

In this case, you should now really use AVTs. This is going to make
your job much easier. But if you really need to use position() in a
ref, instead of .[position() = 42], write: if (position() = 42) then .
else (). This way position() is evaluated in the "right" context.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.com/


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Re: Re: alternate row in repeat with xforms:group doesn't works fine

ricetrac
Hello
I can't use AVTs because I work with orbeon 3.5 and we can't upgrade to 3.6 now. It's too late.
I will try with "if  position()..".
Thank you.


-----Message d'origine-----
De : [hidden email] [mailto:[hidden email]] De la part de Alessandro Vernet
Envoyé : mercredi 12 mars 2008 05:15
À : [hidden email]
Objet : [ops-users] Re: Re: alternate row in repeat with xforms:group doesn't works fine

Julien,

On Fri, Mar 7, 2008 at 9:20 AM, Erik Bruchez <[hidden email]> wrote:
>  The reason your example doesn't work is that position(), in XPath, is  
> always evaluated within a certain context. As soon as you put square  
> brackets ("[...]"), the context is changed, and position() always  
> returns 1 in that case.

In this case, you should now really use AVTs. This is going to make your job much easier. But if you really need to use position() in a ref, instead of .[position() = 42], write: if (position() = 42) then .
else (). This way position() is evaluated in the "right" context.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/

This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: RE: Re: Re: alternate row in repeat with xforms:group doesn't works fine

Alessandro Vernet
Administrator
On Wed, Mar 12, 2008 at 1:45 AM, Bittard, Julien
<[hidden email]> wrote:
>  I can't use AVTs because I work with orbeon 3.5 and we can't upgrade to 3.6 now. It's too late.
>  I will try with "if  position()..".

I see. Hopefully you will be able to upgrade soon and benefit from all
the features that have been added since 3.5 :). The if () works in the
nightly builds and I am pretty sure it worked in 3.6, but there might
have been a problem with the context position in earlier versions.
Testing will tell.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.com/


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws