Domanda

Ho una domanda per quanto riguarda la presentazione dei contenuti form con p:commandbutton che tende a lavoro nel modo Ajax.

Se ho un codice come questo:

<f:verbatim  rendered="#{myBean.constructor}"></f:verbatim >
 <h:form prependId="false">
          ....            
            .....
<p:commandButton   value="#{msg.Add_Parameter_Set}" update="addParameterSetPnl,msgs"  action="#{myBean.initNewParametersSet}"/>
  </h:form>

Al momento della presentazione del modulo con il pulsante di comando, sarà il metodo getContructor da f: Verbatim essere chiamato (aggiorno diverse parti del modulo)? Come posso impedire che venga chiamato?

ho pensato che la presentazione di una forma, rende solo il contenuto della forma / contenuto che è stato specificato dal parametro update ..

È stato utile?

Soluzione

Non dovrebbe danneggiare. Se stai facendo roba costosa in là, allora si dovrebbe passare che per il metodo di costruzione, @PostConstruct o l'azione del fagiolo in questione, o introdurre lazy loading o fase sniffing.

// In Constructor..
public Bean() {
    constructed = getItSomehow();
}

// ..or @PostConstruct..
@PostConstruct
public void init() {
    constructed = getItSomehow();
}

// ..or action method..
public String submit() {
    constructed = getItSomehow();
    return "outcome";
}

// ..or lazy loading..
public boolean getConstructed() {
    if (constructed == null) constructed = getItSomehow();
    return constructed;
}

// ..or phase sniffing (this one updates during render response only).
public boolean getConstructed() {
    if (FacesContext.getCurrentInstance().getRenderResponse()) constructed = getItSomehow();
    return constructed;
}

Vedi anche

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top