문제

I am using Icefaces 3.2. I would like to know how to reset the styleClass attribute of a component e.g textarea from the backing bean method.

USECASE: I have an ace:textAreaEntry which has a validator method in the backing bean. In this backing bean I am doing some validation. If the validation fails I want a particular CSS class applied to the component. So I want to reset the value of the styleclass attribute.

도움이 되었습니까?

해결책

You can set the styleClass conditionally ,like this

<ace:textAreaEntry 
    styleClass="#{facesContext.validationFailed?'failedClass':'validClass'}"/>

or assign fail class only and otherwise no class at all

<ace:textAreaEntry 
    styleClass="#{facesContext.validationFailed?'failedClass':''}"/>

If you manually set message to be displayed in your page you can check if facesContext.messageList is empty or not, like this

<ace:textAreaEntry 
    styleClass="#{(not empty facesContext.messageList)?'filedClass':'validClass'}"/>

If you want to test for some specific internal logic validation you can check for some boolean for example

<ace:textAreaEntry 
    styleClass="#{(myBean.someComponentFailed)?'filedClass':'validClass'}"/>

where someComponentFailed is some property that you set to true/false upon validation failure

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top