Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>During the apply request values phase, the <a href="http://docs.oracle.com/javaee/6/api/javax/faces/component/UIComponent.html#decode%28javax.faces.context.FacesContext%29" rel="nofollow noreferrer"><code>decode()</code></a> method of all <code>UIComponent</code> instances in the component tree is executed. This is where the necessary HTTP request parameters are checked and collected. In case of <code>UIInput</code> components (<code>&lt;h:inputText&gt;</code> and friends), the submitted value is been obtained. In case of <code>UICommand</code> components (<code>&lt;h:commandButton&gt;</code> and friends), the <code>ActionEvent</code> is been queued. </p> <p>In case of <code>&lt;p:commandButton&gt;</code> all the magic happens in <a href="http://grepcode.com/file/repository.primefaces.org/org.primefaces/primefaces/3.5/org/primefaces/component/commandbutton/CommandButtonRenderer.java#CommandButtonRenderer" rel="nofollow noreferrer"><code>CommandButtonRenderer#decode()</code></a> whom a relevant part of the <a href="http://grepcode.com/file/repository.primefaces.org/org.primefaces/primefaces/3.5/org/primefaces/component/commandbutton/CommandButtonRenderer.java#CommandButtonRenderer" rel="nofollow noreferrer">source code</a> is extracted below (line numbers are from PrimeFaces 3.5):</p> <pre><code>34 public void decode(FacesContext context, UIComponent component) { 35 CommandButton button = (CommandButton) component; 36 if(button.isDisabled()) { 37 return; 38 } 39 40 String param = component.getClientId(context); 41 if(context.getExternalContext().getRequestParameterMap().containsKey(param)) { 42 component.queueEvent(new ActionEvent(component)); 43 } 44 } </code></pre> <p>If you're familiar with <a href="http://www.htmldog.com/guides/html/" rel="nofollow noreferrer">basic HTML</a>, you should already know that the <code>name=value</code> pair of every input element and only the pressed button of the enclosing form is been sent as request parameter to the server. The PrimeFaces command button generates basically the following HTML,</p> <pre><code>&lt;button type="submit" name="formId:buttonId" ... /&gt; </code></pre> <p>where <code>formId:buttonId</code> is printed from <code>UIComponent#getClientId()</code>. It's exactly this value which is been used as HTTP request parameter name (the HTTP request parameter value is the button's label, but that's not further relevant here). If you're familiar with <a href="https://stackoverflow.com/tags/servlets/info">basic Servlets</a>, which JSF runs on top of, then you should also already know that request parameters are available by <code>HttpServletRequest#getParameter()</code>, including the <code>name=value</code> pair of the buttons. This allows <a href="https://stackoverflow.com/questions/11830351/multiple-submit-buttons-in-the-same-form-calling-different-servlets/11830483#11830483">distinguishing the pressed button</a>.</p> <p>As you see in the above <code>decode()</code> method, exactly this <code>UIComponent#getClientId()</code> value is also been used in order to check if the HTTP request parameter map contains the parameter name. If so, then an <code>ActionEvent</code> will be queued which ultimately get invoked during invoke application phase.</p> <p>As to the EL arguments, it's actually no rocket science. The whole EL expression is just executed during invoke application phase. It's not so that it's been executed during generating the HTML output of the form and then in some way passed as request parameter. No, it's just been executed during the actual invoke application phase.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload