Reputation: 11
I would like to check whether an arrayList contains a specific element within a JSF.
ArrayList is nonTradList containing couple of values. sProcessorView is the instance of Java class
JSF page is something like below -
<h:commandButton id="p"
value="#{msgs['SP.Pend.Button.Label']}"
type="button"
disabled="#{securityView.readOnlyUser or sPView.readOnly}">
<rich:toolTip style="white-space:nowrap" value="Ctrl-Shft-P" />
<a4j:support event="onclick"
oncomplete="if ((!#{sProcessorView.autoFetchNext}) &&
#{sProcessorView.nonTradList.contains('100')} &&
#{spProcessorView.nonTradList.contains('111')} ) openSimplePop() ;
else openModal();" />
</h:commandButton>
Is there any EL is already there or I have to write some custom tag?
Can we also call a Java method from this JSF to get the result?
Any help is really appreciated on this
Upvotes: 0
Views: 656
Reputation: 1082
You can create a method on your ManagedBean that returns a boolean
public boolean containsValue() {
//Check if the value is in the list...
}
And on your page, you can do this:
var showModal = #{bean.containsValue()};
if(showModal) {
openModal();
} else openSimplePop();
Doing this way, you can check if the list on your ManagedBean contains the value, if so the method will return true, which will be set on the JS variable.
Upvotes: 1