You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Florian Reiser <fl...@softproject.de> on 2008/08/06 11:04:04 UTC

Extending the default renders of input components

Hello,

 

I want to render input components with a red background if validation
failed.

To enable this behaviour for all components I thought of writing a decorator
for the renderers,

which appends a specific css-class to the fields if the validation failed.

 

How do I tell jsf to decorate the renderers?

 

With kind regards

Florian Reiser


Re: Extending the default renders of input components

Posted by Carsten Pieper <ca...@continentale.de>.
Hi Florian,

although this is an older thread... Your solution seems to be interesting 
but we're wondering whether it's only technically feasible in JSF 1.2?
(we're still on Trinidad 1.0.x)

If not, it would be very nice of you, if you could share some more details!

Thanks in advance,
Carsten



Florian Reiser-3 wrote:
> 
> Thanks for all your suggestions.
> In the mean time I have solved my issue with a custom validation phase 
> listener.
> After the validation it appends an error style class to the styleClass 
> attribute of the components with messages.
> 
> With kind regards
> Florian
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Extending-the-default-renders-of-input-components-tp18847082p23757646.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Extending the default renders of input components

Posted by Florian Reiser <fl...@softproject.de>.
Thanks for all your suggestions.
In the mean time I have solved my issue with a custom validation phase 
listener.
After the validation it appends an error style class to the styleClass 
attribute of the components with messages.

With kind regards
Florian

"Matt Cooper" <ma...@gmail.com> schrieb im Newsbeitrag 
news:f8eab54d0808060911l4fe76141s7efc7f7c3025a71d@mail.gmail.com...
>I think using a custom skin would be more robust.  I wonder if
> defining a skin extension with the following definition would be
> sufficient:
>
> af|inputText:error::content {
>  background-color: red;
> }
>
> This definition means that the the background-color applies to the
> internal psuedo-element named "content" of the the inputText component
> when the inputText is in an "error" state.
>
> (I have not tested this myself.)
>
> Regards,
> Matt
>
> On Wed, Aug 6, 2008 at 8:46 AM, Matthias Wessendorf <ma...@apache.org> 
> wrote:
>> Hi,
>>
>> in the past I wrote a blog entry about how to extend the Trinidad 
>> renderers.
>> Perhaps that helps you as well (see [1]).
>>
>> -Matthias
>>
>> [1] 
>> http://matthiaswessendorf.wordpress.com/2008/02/20/extending-trinidads-default-renderers/
>>
>> On Wed, Aug 6, 2008 at 4:38 PM,  <F....@delagelanden.com> wrote:
>>> Hi,
>>>
>>> I recently started using a custom OutputLabelRenderer which is a 
>>> subclass of
>>> the Trinidad's default renderer.
>>> I don't know if you can decorate an existing renderer.
>>>
>>> To replace the default OutputLabelRenderer I put the following fragment 
>>> in
>>> faces-config.xml
>>>
>>>   <render-kit>
>>> 
>>> <render-kit-id>org.apache.myfaces.trinidadinternal.core</render-kit-id>
>>>     <!-- render-kit-class></render-kit-class -->
>>>     <renderer>
>>>
>>> <component-family>org.apache.myfaces.trinidad.Output</component-family>
>>>       <renderer-type>org.apache.myfaces.trinidad.Label</renderer-type>
>>>
>>> <renderer-class>com.mycompany.jsf.renderkit.core.xhtml.OutputLabelRenderer</renderer-class>
>>>     </renderer>
>>>   </render-kit>
>>>
>>> I did have some trouble finding out which renderkit id to use. If you 
>>> don;t
>>> use the correct id the default may still be used instead of your own.
>>>
>>> Hope this helps.
>>> Good luck,
>>>
>>> Freek Segers
>>>
>>> ________________________________
>>> From: Florian Reiser [mailto:florian.reiser@softproject.de]
>>> Sent: 06 augustus 2008 11:04
>>> To: MyFaces Discussion
>>> Subject: Extending the default renders of input components
>>>
>>> Hello,
>>>
>>>
>>>
>>> I want to render input components with a red background if validation
>>> failed.
>>>
>>> To enable this behaviour for all components I thought of writing a 
>>> decorator
>>> for the renderers,
>>>
>>> which appends a specific css-class to the fields if the validation 
>>> failed.
>>>
>>>
>>>
>>> How do I tell jsf to decorate the renderers?
>>>
>>>
>>>
>>> With kind regards
>>>
>>> Florian Reiser
>>>
>>> ================================================
>>> The information transmitted via this e-mail is intended only for the 
>>> person
>>> or entity to which it is addressed and may contain confidential and/or
>>> privileged material.  Any review, retransmission, dissemination or other 
>>> use
>>> of, or taking of any action in reliance upon this information by persons 
>>> or
>>> entities other than the intended recipient is prohibited. If you 
>>> received
>>> this in error, please contact the sender and delete the material from 
>>> any
>>> computer.
>>>
>>
>>
>>
>> --
>> Matthias Wessendorf
>>
>> further stuff:
>> blog: http://matthiaswessendorf.wordpress.com/
>> sessions: http://www.slideshare.net/mwessendorf
>> mail: matzew-at-apache-dot-org
>>
> 



Re: Extending the default renders of input components

Posted by Matt Cooper <ma...@gmail.com>.
I think using a custom skin would be more robust.  I wonder if
defining a skin extension with the following definition would be
sufficient:

af|inputText:error::content {
  background-color: red;
}

This definition means that the the background-color applies to the
internal psuedo-element named "content" of the the inputText component
when the inputText is in an "error" state.

(I have not tested this myself.)

Regards,
Matt

On Wed, Aug 6, 2008 at 8:46 AM, Matthias Wessendorf <ma...@apache.org> wrote:
> Hi,
>
> in the past I wrote a blog entry about how to extend the Trinidad renderers.
> Perhaps that helps you as well (see [1]).
>
> -Matthias
>
> [1] http://matthiaswessendorf.wordpress.com/2008/02/20/extending-trinidads-default-renderers/
>
> On Wed, Aug 6, 2008 at 4:38 PM,  <F....@delagelanden.com> wrote:
>> Hi,
>>
>> I recently started using a custom OutputLabelRenderer which is a subclass of
>> the Trinidad's default renderer.
>> I don't know if you can decorate an existing renderer.
>>
>> To replace the default OutputLabelRenderer I put the following fragment in
>> faces-config.xml
>>
>>   <render-kit>
>>    <render-kit-id>org.apache.myfaces.trinidadinternal.core</render-kit-id>
>>     <!-- render-kit-class></render-kit-class -->
>>     <renderer>
>>
>> <component-family>org.apache.myfaces.trinidad.Output</component-family>
>>       <renderer-type>org.apache.myfaces.trinidad.Label</renderer-type>
>>
>> <renderer-class>com.mycompany.jsf.renderkit.core.xhtml.OutputLabelRenderer</renderer-class>
>>     </renderer>
>>   </render-kit>
>>
>> I did have some trouble finding out which renderkit id to use. If you don;t
>> use the correct id the default may still be used instead of your own.
>>
>> Hope this helps.
>> Good luck,
>>
>> Freek Segers
>>
>> ________________________________
>> From: Florian Reiser [mailto:florian.reiser@softproject.de]
>> Sent: 06 augustus 2008 11:04
>> To: MyFaces Discussion
>> Subject: Extending the default renders of input components
>>
>> Hello,
>>
>>
>>
>> I want to render input components with a red background if validation
>> failed.
>>
>> To enable this behaviour for all components I thought of writing a decorator
>> for the renderers,
>>
>> which appends a specific css-class to the fields if the validation failed.
>>
>>
>>
>> How do I tell jsf to decorate the renderers?
>>
>>
>>
>> With kind regards
>>
>> Florian Reiser
>>
>> ================================================
>> The information transmitted via this e-mail is intended only for the person
>> or entity to which it is addressed and may contain confidential and/or
>> privileged material.  Any review, retransmission, dissemination or other use
>> of, or taking of any action in reliance upon this information by persons or
>> entities other than the intended recipient is prohibited. If you received
>> this in error, please contact the sender and delete the material from any
>> computer.
>>
>
>
>
> --
> Matthias Wessendorf
>
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org
>

Re: Extending the default renders of input components

Posted by Matthias Wessendorf <ma...@apache.org>.
Hi,

in the past I wrote a blog entry about how to extend the Trinidad renderers.
Perhaps that helps you as well (see [1]).

-Matthias

[1] http://matthiaswessendorf.wordpress.com/2008/02/20/extending-trinidads-default-renderers/

On Wed, Aug 6, 2008 at 4:38 PM,  <F....@delagelanden.com> wrote:
> Hi,
>
> I recently started using a custom OutputLabelRenderer which is a subclass of
> the Trinidad's default renderer.
> I don't know if you can decorate an existing renderer.
>
> To replace the default OutputLabelRenderer I put the following fragment in
> faces-config.xml
>
>   <render-kit>
>    <render-kit-id>org.apache.myfaces.trinidadinternal.core</render-kit-id>
>     <!-- render-kit-class></render-kit-class -->
>     <renderer>
>
> <component-family>org.apache.myfaces.trinidad.Output</component-family>
>       <renderer-type>org.apache.myfaces.trinidad.Label</renderer-type>
>
> <renderer-class>com.mycompany.jsf.renderkit.core.xhtml.OutputLabelRenderer</renderer-class>
>     </renderer>
>   </render-kit>
>
> I did have some trouble finding out which renderkit id to use. If you don;t
> use the correct id the default may still be used instead of your own.
>
> Hope this helps.
> Good luck,
>
> Freek Segers
>
> ________________________________
> From: Florian Reiser [mailto:florian.reiser@softproject.de]
> Sent: 06 augustus 2008 11:04
> To: MyFaces Discussion
> Subject: Extending the default renders of input components
>
> Hello,
>
>
>
> I want to render input components with a red background if validation
> failed.
>
> To enable this behaviour for all components I thought of writing a decorator
> for the renderers,
>
> which appends a specific css-class to the fields if the validation failed.
>
>
>
> How do I tell jsf to decorate the renderers?
>
>
>
> With kind regards
>
> Florian Reiser
>
> ================================================
> The information transmitted via this e-mail is intended only for the person
> or entity to which it is addressed and may contain confidential and/or
> privileged material.  Any review, retransmission, dissemination or other use
> of, or taking of any action in reliance upon this information by persons or
> entities other than the intended recipient is prohibited. If you received
> this in error, please contact the sender and delete the material from any
> computer.
>



-- 
Matthias Wessendorf

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

RE: Extending the default renders of input components

Posted by F....@delagelanden.com.
Hi,
 
I recently started using a custom OutputLabelRenderer which is a
subclass of the Trinidad's default renderer.
I don't know if you can decorate an existing renderer.
 
To replace the default OutputLabelRenderer I put the following fragment
in faces-config.xml
 
  <render-kit>
 
<render-kit-id>org.apache.myfaces.trinidadinternal.core</render-kit-id>
    <!-- render-kit-class></render-kit-class -->
    <renderer>
 
<component-family>org.apache.myfaces.trinidad.Output</component-family>
      <renderer-type>org.apache.myfaces.trinidad.Label</renderer-type>
 
<renderer-class>com.mycompany.jsf.renderkit.core.xhtml.OutputLabelRender
er</renderer-class>
    </renderer>
  </render-kit>


I did have some trouble finding out which renderkit id to use. If you
don;t use the correct id the default may still be used instead of your
own.
 
Hope this helps.
Good luck,
 
Freek Segers

________________________________

	From: Florian Reiser [mailto:florian.reiser@softproject.de] 
	Sent: 06 augustus 2008 11:04
	To: MyFaces Discussion
	Subject: Extending the default renders of input components
	
	

	Hello,

	 

	I want to render input components with a red background if
validation failed.

	To enable this behaviour for all components I thought of writing
a decorator for the renderers,

	which appends a specific css-class to the fields if the
validation failed.

	 

	How do I tell jsf to decorate the renderers?

	 

	With kind regards

	Florian Reiser



================================================
The information transmitted via this e-mail is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material.  Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.