Phillip Byram
Phillip Byram

Reputation: 70

Conditional Operator in value attribute workaround

I'm trying to do the equivalent of:

<h:inputHidden value="#{playerBean==null?null:playerBean.wavRecorded}"/>

However, the conditional operator cannot be used in value tags according to:

Using conditional operator in h:inputText value and h:commandButton actionListener

I tried doing part 2 of the answer in the above article, but ran into issues.

I'd like to know how to do part 1 in the answer, but I don't need to use actionlisteners etc.. Is there a simple workaround to getting a conditional statement in another tag to populate the value in this hidden input?

Thanks

Upvotes: 0

Views: 743

Answers (1)

davehenry
davehenry

Reputation: 1076

Sure, you can use <c:set> as indicated in this answer. It would look something like this:

<c:set var="wavRecorded" value="#{playerBean==null?null:playerBean.wavRecorded}" scope="request" />

And then:

<h:inputHidden value="#{wavRecorded}"/>

Upvotes: 1

Related Questions