jsf 2.2 - Params of button always empty even after clicking jsf -


i opening modal has form in it. trying check if button clicked or not #{empty param['buttonid']}. shows empty when clicked.

<div class="modal fade" jsf:id="datareset">         <div class="modal-dialog">              <form jsf:id="reset-data-form" class="form-horizontal">                 <div class="modal-content">                     <div class="modal-header">                                           <h4 class="modal-title">modal header</h4>                     </div>                     <div class="modal-body">                         <div class="form-group">                             <label for="inputemail" class="col-sm-3 control-label">email</label>                             <div class="col-sm-9">                                 <input type="text" class="form-control"                                         jsf:id="inputemail" jsf:value="#{dataresetfacade.dataresetemail}"                                                                  name="inputemail" />                                 <h:message for="inputemail" p:class="error-msg"/>                             </div>                         </div>                     </div>                     <div class="modal-footer">                         <button class="btn btn-default"                             data-dismiss="modal">#{msg['general.button.cancel']}</button>                         <button class="btn btn-primary" jsf:id="reset-data-button"                              jsf:action="#{dataresetfacade.resetdata}">submit                             <f:ajax execute="@form" render="@form aaa bbb messages" onevent="close"/>                         </button>                          <h:outputtext id="aaa" value="#{not empty param['reset-data-button']}"/>                          <h:outputtext id="bbb" value="#{empty param['reset-data-button']}"/>                     </div>                 </div>             </form>         </div>     </div> 

am doing thing wrong.

you did not specify right request parameter name there. request parameter name jsf component's client id. client id of jsf input , button component represented html element's name attribute. can find out looking @ jsf-generated html output via rightclick, view source in webbrowser.

given current view, that'll below:

<button name="reset-data-form:reset-data-button" ... /> 

alter parameter names accordingly:

<h:outputtext id="aaa" value="#{not empty param['reset-data-form:reset-data-button']}" /> <h:outputtext id="bbb" value="#{empty param['reset-data-form:reset-data-button']}" /> 

alternatively, bind jsf uicomponent instance unique variable name in facelet scope using binding attribute , let jsf evaluate uicomponent#getclientid().

<button jsf:binding="#{resetbutton}" ... /> ... <h:outputtext id="aaa" value="#{not empty param[resetbutton.clientid]}" /> <h:outputtext id="bbb" value="#{empty param[resetbutton.clientid]}" /> 

note: not bind bean property. above code as-is.

see also:


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -