• Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing default attribute values

 
Eelke Klein
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks for the suggestion. Putting the h:messages element in the layout will be good enough in most cases.
 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • 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.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!