Skip to main content
Bounty Ended with 50 reputation awarded by satya prakash Panigrahi
button's param is apparently empty when ajax=false is used..??
Source Link
BalusC
  • 1.1m
  • 375
  • 3.6k
  • 3.6k

As per the question's comments you appear to need action-dependent validation. So the calendar should only be validated as required when a specific action is invoked, which is the main command button action, not the ajax listener action.

This can be solved as per the guidelines found in the related question: Validate input as required only if certain command button is pressed.

<p:calendar ... required="#{not empty param[mainCommandButtonparam.clientId]containsKey(mainCommandButton.clientId)}">
    <p:ajax ... />
</p:calendar>
...
<p:commandButton binding="#{mainCommandButton}" ... />

And, in order to retain the 'required asterisk' of the associated <p:outputLabel>, simply set its indicateRequired attribute to true. It will otherwise default to auto and only be applied when the UIInput#isRequired() of the associated input component returns true during render response phase.

<p:outputLabel ... indicateRequired="true" />

As per the question's comments you appear to need action-dependent validation. So the calendar should only be validated as required when a specific action is invoked, which is the main command button action, not the ajax listener action.

This can be solved as per the guidelines found in the related question: Validate input as required only if certain command button is pressed.

<p:calendar ... required="#{not empty param[mainCommandButton.clientId]}">
    <p:ajax ... />
</p:calendar>
...
<p:commandButton binding="#{mainCommandButton}" ... />

And, in order to retain the 'required asterisk' of the associated <p:outputLabel>, simply set its indicateRequired attribute to true. It will otherwise default to auto and only be applied when the UIInput#isRequired() of the associated input component returns true during render response phase.

<p:outputLabel ... indicateRequired="true" />

As per the question's comments you appear to need action-dependent validation. So the calendar should only be validated as required when a specific action is invoked, which is the main command button action, not the ajax listener action.

This can be solved as per the guidelines found in the related question: Validate input as required only if certain command button is pressed.

<p:calendar ... required="#{param.containsKey(mainCommandButton.clientId)}">
    <p:ajax ... />
</p:calendar>
...
<p:commandButton binding="#{mainCommandButton}" ... />

And, in order to retain the 'required asterisk' of the associated <p:outputLabel>, simply set its indicateRequired attribute to true. It will otherwise default to auto and only be applied when the UIInput#isRequired() of the associated input component returns true during render response phase.

<p:outputLabel ... indicateRequired="true" />
Source Link
BalusC
  • 1.1m
  • 375
  • 3.6k
  • 3.6k

As per the question's comments you appear to need action-dependent validation. So the calendar should only be validated as required when a specific action is invoked, which is the main command button action, not the ajax listener action.

This can be solved as per the guidelines found in the related question: Validate input as required only if certain command button is pressed.

<p:calendar ... required="#{not empty param[mainCommandButton.clientId]}">
    <p:ajax ... />
</p:calendar>
...
<p:commandButton binding="#{mainCommandButton}" ... />

And, in order to retain the 'required asterisk' of the associated <p:outputLabel>, simply set its indicateRequired attribute to true. It will otherwise default to auto and only be applied when the UIInput#isRequired() of the associated input component returns true during render response phase.

<p:outputLabel ... indicateRequired="true" />