Reputation: 13
I am adding JSF components dynamically into an XHTML page created using JSF 1.2 with facelets. The required validation of some of these components have to be carried out only when a specfic button in the page is clicked. So I've added the required attribute as an EL expression using the code:
String requiredExpression = "#{not empty param['form:button']}")
component.setValueExpression("required",
createValueExpression(requiredExpression, String.class));
I have verified that the EL expression works by placing it in the required attribute of one of the static components in the page. I have also verified that the EL expression is getting added to the component by debugging the code. But it just does not work in the dynamic components.
Upvotes: 1
Views: 447
Reputation: 1108692
The expression must evaluate to a boolean
, not a String
.
Replace
createValueExpression(requiredExpression, String.class)
by
createValueExpression(requiredExpression, boolean.class)
Upvotes: 1