Dynamic clay in a datatable

View: New views
4 Messages — Rating Filter:   Alert me  

Parent Message unknown Dynamic clay in a datatable

by drh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello, I know similar questions was made in the past but I haven't found
a response. I'm trying to render an HTML that depends of the current
datatable row value,  but the result is that all render the same page:

This is the code:

--------------------
<t:dataTable value="#{home.banners}" var="c">
        <t:column>
                <clay:clay id="prueba" jsfid="WDynamicClay" managedBeanName="c">
            <c:symbol name="page" value="#{@managed-bean-name.jsfid}"/>
              </clay:clay>
        </t:column>
</t:dataTable>
--------------------

And "WDynamicClay" is an xml component definition:

--------------------
<component jsfid="WDynamicClay" extends="clay">
        <attributes>
            <set name="clayJsfid" value="@page"/>
        </attributes>
</component>    
--------------------

The managedBeanName's attribute "jsfid" returns a different clay html template but always the last template is rendered.
I tried other alternatives but always with identical result:

- Using a ShapeValidator
- Create a JSF component that adds a clay component
- Extending the Clay component

Thanks in advance.
Daniel del Río.


Re: Dynamic clay in a datatable

by Ryan Wynn-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Could you try first this more direct way and see what happens?

--------------------
<t:dataTable value="#{home.banners}" var="c">
       <t:column>
               <clay:clay id="prueba" jsfid="#{c.jsfid}"></clay:clay>
       </t:column>
</t:dataTable>
--------------------

Not sure that the symbol tag is being evaluated in time to be
available for the clay component.

I have not used clay's jsp tags but have done something like this
before with html templates.

Ryan




On Jan 18, 2008 1:46 PM, Daniel del Río <dani@...> wrote:

> Hello, I know similar questions was made in the past but I haven't found
> a response. I'm trying to render an HTML that depends of the current
> datatable row value,  but the result is that all render the same page:
>
> This is the code:
>
> --------------------
> <t:dataTable value="#{home.banners}" var="c">
>         <t:column>
>                 <clay:clay id="prueba" jsfid="WDynamicClay" managedBeanName="c">
>                         <c:symbol name="page" value="#{@managed-bean-name.jsfid}"/>
>                 </clay:clay>
>         </t:column>
> </t:dataTable>
> --------------------
>
> And "WDynamicClay" is an xml component definition:
>
> --------------------
> <component jsfid="WDynamicClay" extends="clay">
>         <attributes>
>             <set name="clayJsfid" value="@page"/>
>         </attributes>
> </component>
> --------------------
>
> The managedBeanName's attribute "jsfid" returns a different clay html template but always the last template is rendered.
> I tried other alternatives but always with identical result:
>
> - Using a ShapeValidator
> - Create a JSF component that adds a clay component
> - Extending the Clay component
>
> Thanks in advance.
> Daniel del Río.
>
>

Parent Message unknown Re: Dynamic clay in a datatable

by Gary%20VanMatre :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

From: Daniel del Río <dani@...>

> Hello, I know similar questions was made in the past but I haven't found
> a response. I'm trying to render an HTML that depends of the current
> datatable row value, but the result is that all render the same page:
>
>This is the code:
>
>--------------------
><t:dataTable value="#{home.banners}" var="c">
> <t:column>
><clay:clay id="prueba" jsfid="WDynamicClay" managedBeanName="c">
>             <c:symbol name="page"
>value="#{@managed-bean-name.jsfid}"/>
>               </clay:clay>
> </t:column>
></t:dataTable>
>--------------------
>
>And "WDynamicClay" is an xml component definition:
>
>--------------------
><component jsfid="WDynamicClay" extends="clay">
 ><attributes>
>            <set name="clayJsfid" value="@page"/>
>        </attributes>
></component>    
>--------------------
>
> The managedBeanName's attribute "jsfid" returns a different clay html template
> but always the last template is rendered.
> I tried other alternatives but always with identical result:
>

Unfortunately, you can not use Clay this way in a dataTable.  A data table is a UIData component.  These types of components implement the flyweight pattern.  One set of component definitions for a column is applied to each row as the model as it is iterated over.  For this to work, the clay component would need to rebuild the subtree for each row.  I'm pretty sure that only one attempt to find the clay config beans that build the subtree is made.  The subtree creates "first class components" that are added to the component tree under the clay component (children).  A dynamic subtree in a datatable would most likely cause all kinds of problems with state saving too.
   

> - Using a ShapeValidator
> - Create a JSF component that adds a clay component
> - Extending the Clay component
>
> Thanks in advance.
> Daniel del Río.
>

Gary

Re: Dynamic clay in a datatable

by drh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Finally I found a solution! Thanks Gary to point me on the right way.
In resume, it consists in duplicate the clay component for every
distinct jsfid (every clay page template), and setting the rendered
property accordingly.
To achieve it the more easy way I found is to create a new jsf component
that adds 1 child for page setting the rendered attribute with a value
expression.

Thanks.

El vie, 18-01-2008 a las 15:06 -0500, Ryan Wynn escribió:

> Could you try first this more direct way and see what happens?
>
> --------------------
> <t:dataTable value="#{home.banners}" var="c">
>        <t:column>
>                <clay:clay id="prueba" jsfid="#{c.jsfid}"></clay:clay>
>        </t:column>
> </t:dataTable>
> --------------------
>
> Not sure that the symbol tag is being evaluated in time to be
> available for the clay component.
>
> I have not used clay's jsp tags but have done something like this
> before with html templates.
>
> Ryan
>
>
>
>
> On Jan 18, 2008 1:46 PM, Daniel del Río <dani@...> wrote:
> > Hello, I know similar questions was made in the past but I haven't found
> > a response. I'm trying to render an HTML that depends of the current
> > datatable row value,  but the result is that all render the same page:
> >
> > This is the code:
> >
> > --------------------
> > <t:dataTable value="#{home.banners}" var="c">
> >         <t:column>
> >                 <clay:clay id="prueba" jsfid="WDynamicClay" managedBeanName="c">
> >                         <c:symbol name="page" value="#{@managed-bean-name.jsfid}"/>
> >                 </clay:clay>
> >         </t:column>
> > </t:dataTable>
> > --------------------
> >
> > And "WDynamicClay" is an xml component definition:
> >
> > --------------------
> > <component jsfid="WDynamicClay" extends="clay">
> >         <attributes>
> >             <set name="clayJsfid" value="@page"/>
> >         </attributes>
> > </component>
> > --------------------
> >
> > The managedBeanName's attribute "jsfid" returns a different clay html template but always the last template is rendered.
> > I tried other alternatives but always with identical result:
> >
> > - Using a ShapeValidator
> > - Create a JSF component that adds a clay component
> > - Extending the Clay component
> >
> > Thanks in advance.
> > Daniel del Río.
> >
> >
--
------------------------------
Daniel del Río
Software Architect
t. 690211287
e. dani@...

www.programaria.com
------------------------------