JSF 2.0 Submit form with IncludeViewParams (ignoring empty parameters)

Is it possible to submit a JSF 2.0 form using GET without including those empty values?

    <h:form>
      <h:InputText value="#{bean.item}" id="item">
      <h:commandButton value="Submit" 
         action="submit?faces-redirect=true&amp;includeViewParams=true"/>
    </h:form>

If the item is not an empty string, the query

/submit.jsf?item=test 

But if the item is an empty string, the request

/submit.jsf
+3
source share
1 answer

you can try this

<h:form>
  <h:InputText value="#{bean.item}" id="item">
  <h:commandButton value="Submit" 
     action="#{bean.checkparam}"/>
</h:form>

bean

    public String checkparam(){
 if(bean.getItem =! null){
return "/submit?faces-redirect=true&amp;includeViewParams=true";
   }else{ 
 return "/submit.jsf"
    }
   }
0
source

Source: https://habr.com/ru/post/1789526/


All Articles