myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Lessard" <simon.lessar...@gmail.com>
Subject Re: Why is the styleClass Property always overridden?
Date Tue, 04 Mar 2008 14:23:02 GMT
Oups, should be p_AFError, sorry.

On Tue, Mar 4, 2008 at 9:08 AM, Simon Lessard <simon.lessard.3@gmail.com>
wrote:

> Hello Thomas,
>
> contentStyle add direct CSS style, it's the inlineStyle equivalent applied
> to the content area. As for your use case, here's what you should be able to
> do:
>
> In the skin:
> af|inputText:error af|inputText::content
> {
>   border-color: red;
>   border-style: solid;
>   border-width: 2px;
> }
>
>
> In the page:
> <tr:inputText styleClass="#{backing.styleClass}" binding="#{backing.input
> }"/>
>
> In the bean:
> private UIComponent input;
>
> public UIComponent getInput()
> {
>   return input;
> }
>
> public void setInputUIComponent input)
> {
>   this.input = input;
> }
>
> public String getStyleClass()
> {
>   FacesContext context = FacesContext.getCurrentInstance();
>   return context.getMessages(input.getClientId(context)).hasNext() ?
> "p_Error" : null;
> }
>
>
> Regards,
>
> ~ Simon
>
>
> On Tue, Mar 4, 2008 at 8:40 AM, <thomas.asel@mvv.de> wrote:
>
> >   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
> > renderer.
> >
> > 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:
> > **
> > *if*(component *instanceof* UIXComponentBase) {
> >     UIXComponentBase trinidadComponent = (UIXComponentBase) component;
> >     ((FacesBean) trinidadComponent.getFacesBean
> > ()).setProperty(PropertyKey.*createPropertyKey*("styleClass"),
> > styleClass);
> > }
> >
> >  Regards,
> > Tom
> >  ------------------------------
> > *Von:* Simon Lessard [mailto:simon.lessard.3@gmail.com]
> > *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 <simon.lessard.3@gmail.com>
> > 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 <
> > > simon.lessard.3@gmail.com> 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;
> > > >   this.input.setStyleClass("myClass");
> > > > }
> > > >
> > > >
> > > > Regards,
> > > >
> > > > ~ Simon
> > > >
> > > >
> > > > On Mon, Mar 3, 2008 at 1:39 PM, <thomas.asel@mvv.de> 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 Trinidad-Components.
> > > > > 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,
> > > > > Tom
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Thomas Asel
> > > > > Diplom Informatiker (FH)
> > > > > Selbständiger Softwareentwickler
> > > > > im Auftrag der 24/7 IT-Services GmbH
> > > > >
> > > > > == == == == == == == == == == == ==
> > > > > ***www.thomas-asel.de*
> > > > > 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
> > > > >
> > > >
> > > >
> > >
> >
>

Mime
View raw message