myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject AW: Why is the styleClass Property always overridden?
Date Tue, 04 Mar 2008 09:48:52 GMT
Hi Simon, 
thanks for your reply
Well, I also tried the contentStyle attribute but again the only class that shows up in the
vlass Attribute of the rendered <input> tag is 'af_inputText_content'. 
So it seems to me that the trinidad renderer overwrites what ever is ment to show up in the
class attribute with the auto-generated skinning-class.
Anyway, in this case I *have* to change the components attribute programmatically within a
custom renderer for the <h:messages>-tag. Components that are associatedt with thrown
FacesMessages should be visually highlighted by using a certain CSS-class. So I can't just
use binding on the styleClass-Attribute but have zo mnaipulate the component from within the
As described above, it works for JSF standard components, but not for those from Trinidad,
so maybe i should focus on changing attributes of Trinidad-Components. Im not totally sure
how this is done the right way. Ijust can't use the attributes map, right? So I have to use
the FacesBean. How can I change properties on that?
I tried this, but it didnt work:


Von: Simon Lessard [] 
Gesendet: Montag, 3. März 2008 19:58
An: MyFaces Discussion
Betreff: Re: Why is the styleClass Property always overridden?

Wow... really not my day... there's no such attribute... only contentStyle... I always create
it when I make custom components... oh well... JIRA ticket time...

On Mon, Mar 3, 2008 at 1:56 PM, Simon Lessard <> wrote:

	Oups, I misread something. You need to use the contentStyleClass attribute to affect the
input's style class, the styleClass attribute applies the class on the input container. 

	On Mon, Mar 3, 2008 at 1:53 PM, Simon Lessard <> wrote:

		Hello Thomas,
		why don't you simply use <tr:inputText styleClass="myClass"/>? If the class changes
at runtime you can use <tr:inputText styleClass="#{bean.myClass}"/> or programatically:
		<tr:inputText binding="#{bean.input}"/>
		CoreInputText input;
		public CoreInputText getInput()
		  return input;
		public void setInput(CoreInputText input)
		  this.input = input;
		~ Simon 

		On Mon, Mar 3, 2008 at 1:39 PM, <> wrote:

			Hi everybody, 
			Im stuck with a problem and may need a little help to get through. 
			Basically all I want to do is to add the name of a CSS-class programmatically to the styleClass
attribute so that somithing like this is rendered in HTML:

			<input id="myText" class="af_inputText_content myClass" ...> 
			The 'myClass' should be added to the class inserted by the skinning-renderer of Trinidad.

			Even the very basic approach of using the styleClass Attribute of <tr:inputText>
does not work as only af_inputText_content is inserted as value for the class attribute.

			Manipulating the componentes attribute map works for JSF-Standard-Components but not for
			This is what my code looks like: 
			                                Map<String, Object> attributes = component.getAttributes();

			                                String styleClass = (String) attributes.get("styleClass");

			                                // Append myClass to whatever is set as styleClass 
			                                attributes.put("styleClass", styleClass + " myClass");

			Do I have to use the acesBean for Trinidad-Components? If so, how can the styleClass-attribute
be accessed? 

			Thanks in advance, 

			Thomas Asel 
			Diplom Informatiker (FH) 
			Selbständiger Softwareentwickler 
			im Auftrag der 24/7 IT-Services GmbH 

			== == == == == == == == == == == == 
			J2EE und Contentmanagement-Lösungen 
			L13,7 68161 Mannheim 
			Tel.: +49 (0) 621 / 386 448 3 
			Mobil: +49(0) 176 / 219 284 26 
			USt-IdNr.: DE248123620 

View raw message