• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Changing default attribute values

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a simple way to change the default value of an attribute for the whole project? To be specific I do not want to have to specify the errorClass, fatalClass, infoClass and warClass attributes of the h:message[s] tag every time I use one. It add's a lot of code and repetition which is not good.

I guess I good make a composite component for it but I would prefer it if there is a simpler method.
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch!

I'm afraid that there's no way to override the JSF default attribute values. You could define a composite control, although for consistency's sake I normally place the h:messages element in a fixed zone on the page layout (using Facelets). Meaning that I don't have multiple definitions of the messages tag, since the same copy is used for all invocations of the page template.
 
Eelke Klein
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the suggestion. Putting the h:messages element in the layout will be good enough in most cases.
 
Ranch Hand
Posts: 121
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

I have some requirement related to component attributes.
for inputtext component, while rendering is there any way to change only class and title attribute as I want to append the class attribute with errorClass style that makes the inputtext border red in color when there are any error messages and I want to paste the error message into title attribute of that control.
for time being I written a component which is exactly similar to inputtext, but cant I only override the inputtext renderer and accomplish this?

I tried to override the inputext renderer which is rendering as expected but value entered by the user is not set to backing bean where as in a custom component I am using the same logic in its renderer it is working.

your help is appreciated.

 
reply
    Bookmark Topic Watch Topic
  • New Topic