You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shale.apache.org by Gary VanMatre <gv...@comcast.net> on 2006/07/26 18:41:18 UTC

Re: How to define converter/validator/actionListener in Clay's full HTML view without XML configuration?

>From: Ren� Zanner <re...@accelsis.biz> 
>
> Hello, 
> 
> I try to use the full HTML views provided by Clay - if possible without the need 
> for additional component definition(s) in XML. 
> When defining converters (e.g. a DateTimeConverter) like the following: 
> 
>
><span jsfid="outputText" value="#{row.date}">
>   <span jsfid="dateTimeConverter" pattern="dd.MM.yyyy HH:mm:ss.SSS">
>      01.01.1900
>   </span>
></span>
>


The html tapestry like template parsing doesn't allow you to add nested converters, validators and listeners. 
You can use the attribute "converter" if it's a simple converter that doesn't require properties.
<span jsfid="outputText" value="#{row.date}" converter="javax.faces.DateTime">
    01.01.1900
</span>

However, this converter requires custom properties.  You have several options.  If you want to
stay with tapestry like templates, you will need to define a custom clay config component.

HTML:
  <span jsfid="mydate" value="#{row.date}" converter="javax.faces.DateTime">
  
    01.01.1900
  </span>

XML Config:
  <component jsfid="mydate" extends="outputText">
    <converter jsfid="convertDateTime">
       <attributes>
         <set name="pattern" bindingType="dd.MM.yyyy HH:mm:ss.SSS"/>
       </attributes>
    </converter> 
  </component>

Or, you could use the new namespace support.  It would look something like this:

HTML:
<span  xmlns:f="http://java.sun.com/jsf/core"
 xmlns:h="http://java.sun.com/jsf/html">

    <h:outputText value="#{row.date}">
        <f:convertDateTime pattern="dd.MM.yyyy HH:mm:ss.SSS"/>
    </h:outputText>

</span>

Or, yet another flavor of html namespaces:
HTML:
<span xmlns:clay="http://shale.apache.org/xml/clay">
  <clay:element jsfid="outputText">
    <clay:attributes>
        <clay:set name="value" value="#{row.date}"/>
    </clay:attributes>
    <clay:converter jsfid="convertDateTime">
       <clay:attributes>
         <clay:set name="pattern" bindingType="dd.MM.yyyy HH:mm:ss.SSS"/>
       </clay:attributes>
    </clay:converter> 
  </clay:element>

</span>


 
> I receive the following ERRORs: 
> 
> 13:45:23,275 ERROR [ApplicationImpl] Could not instantiate component of type 
> javax.faces.DateTime 
> 13:45:23,322 ERROR [CreateComponentCommand] Cannot create Component 
> renderId="118" jsfid="dateTimeConverter" componentType="javax.faces.DateTime" 
> extends="dateTimeConverter" allowBody="null" facetName="null" 
> 
> Is there a possibility (special attribute of the , special configuration) 
> to add converters/validators/actionListeners and so on via a pure HTML view or 
> do I have to define the component in a clay-config.xml file and add the 
> converters there? 
> 
> Thank you very much, 
> 
> Ren� 


Gary

Re: How to define converter/validator/actionListener in Clay's full HTML view without XML configuration?

Posted by René Zanner <re...@accelsis.biz>.
Hello,

thanks for the quick response! I decided to go with the xml configuration file and did something similar you proposed using an extended "outputText":

  <component jsfid="my:outputDateTime" extends="outputText">
  	<converter jsfid="dateTimeConverter">
  		<attributes>
  			<set name="pattern" value="@pattern" />
  		</attributes>
  	</converter>
  </component>

For a more generalized approach I used the symbol "@pattern" rather like a hard-coded value for the pattern attribute of the converter. This way I'm able to fully re-use this component for other pattern styles:

<span jsfid="my:outputDateTime" pattern="dd.MM.yyyy">#{myView.date}</span>

or

<span jsfid="my:outputDateTime" pattern="HH:mm:ss.SSS">#{myView.time}</span>


Cheers,

René

----- Original Message -----
From: Gary VanMatre
[mailto:gvanmatre@comcast.net]
To: user@shale.apache.org
Sent: Wed, 26 Jul
2006 18:41:18 +0200
Subject: Re: How to define
converter/validator/actionListener in Clay's full HTML view without XML
configuration?


> >From: René Zanner <re...@accelsis.biz> 
> >
> > Hello, 
> > 
> > I try to use the full HTML views provided by Clay - if possible without
> the need 
> > for additional component definition(s) in XML. 
> > When defining converters (e.g. a DateTimeConverter) like the following: 
> > 
> >
> ><span jsfid="outputText" value="#{row.date}">
> >   <span jsfid="dateTimeConverter" pattern="dd.MM.yyyy HH:mm:ss.SSS">
> >      01.01.1900
> >   </span>
> ></span>
> >
> 
> 
> The html tapestry like template parsing doesn't allow you to add nested
> converters, validators and listeners. 
> You can use the attribute "converter" if it's a simple converter that
> doesn't require properties.
> <span jsfid="outputText" value="#{row.date}"
> converter="javax.faces.DateTime">
>     01.01.1900
> </span>
> 
> However, this converter requires custom properties.  You have several
> options.  If you want to
> stay with tapestry like templates, you will need to define a custom clay
> config component.
> 
> HTML:
>   <span jsfid="mydate" value="#{row.date}" converter="javax.faces.DateTime">
>   
>     01.01.1900
>   </span>
> 
> XML Config:
>   <component jsfid="mydate" extends="outputText">
>     <converter jsfid="convertDateTime">
>        <attributes>
>          <set name="pattern" bindingType="dd.MM.yyyy HH:mm:ss.SSS"/>
>        </attributes>
>     </converter> 
>   </component>
> 
> Or, you could use the new namespace support.  It would look something like
> this:
> 
> HTML:
> <span  xmlns:f="http://java.sun.com/jsf/core"
>  xmlns:h="http://java.sun.com/jsf/html">
> 
>     <h:outputText value="#{row.date}">
>         <f:convertDateTime pattern="dd.MM.yyyy HH:mm:ss.SSS"/>
>     </h:outputText>
> 
> </span>
> 
> Or, yet another flavor of html namespaces:
> HTML:
> <span xmlns:clay="http://shale.apache.org/xml/clay">
>   <clay:element jsfid="outputText">
>     <clay:attributes>
>         <clay:set name="value" value="#{row.date}"/>
>     </clay:attributes>
>     <clay:converter jsfid="convertDateTime">
>        <clay:attributes>
>          <clay:set name="pattern" bindingType="dd.MM.yyyy HH:mm:ss.SSS"/>
>        </clay:attributes>
>     </clay:converter> 
>   </clay:element>
> 
> </span>
> 
> 
>  
> > I receive the following ERRORs: 
> > 
> > 13:45:23,275 ERROR [ApplicationImpl] Could not instantiate component of
> type 
> > javax.faces.DateTime 
> > 13:45:23,322 ERROR [CreateComponentCommand] Cannot create Component 
> > renderId="118" jsfid="dateTimeConverter"
> componentType="javax.faces.DateTime" 
> > extends="dateTimeConverter" allowBody="null" facetName="null" 
> > 
> > Is there a possibility (special attribute of the , special configuration) 
> > to add converters/validators/actionListeners and so on via a pure HTML
> view or 
> > do I have to define the component in a clay-config.xml file and add the 
> > converters there? 
> > 
> > Thank you very much, 
> > 
> > René 
> 
> 
> Gary
> 

"binding" attribute of JSF standard components

Posted by René Zanner <re...@accelsis.biz>.
Hi all,

unfortunately the "binding" attribute isn't standard for all JSF components. Will that change in the future? I think it's a required attribute when trying to be conform to the JSF standard...

Otherwise I'm forced to inherit from the standard components provided by clay just to provide the "binding" attribute:

<component jsfid="my:dataTable" extends="dataTable">
  <attributes>
    <set name="binding" value="@binding" />
  </attributes>
</component>

Is it possible to enforce it being a Value Binding (e.g. via bindingType="VB"?)? Other values are not allowed since the value must refer to a UIComponent attribute of a backing bean.

Without this attribute I cannot use something like this in my HTML views:

<table jsfid="my:dataTable" binding="#{tableView.dataTable}" ...>
   ...
</table>

The "binding" is required for dataTable when trying to access the currently selected row after clicking on a command link in a specific row. In this case the row clicked on is contained in the attribute "rowData" of the dataTable: dataTable.getRowData() gives the Object associated with the row in which occurred the mouse click.

Cheers,

René