Pregunta

I cant't understand why in my PrimeFaces view when I call

<f:setPropertyActionListener value="#{item}" target="#{tagController.current}" />

it never calls the backed bean tagController.setCurrent method.

I've the following view:

  <h:form id="tableForm" styleClass="form-horizontal">
    <h:panelGroup id="dataPanel">   
      <p:dataTable value="#{tagController.lazyModel}" 
                   lazy="true"
                   id="table"
                   var="item"
                   paginator="true"
                   rows="10"
                   paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                   rowsPerPageTemplate="10,20,50" >

        <p:column headerText="Name" sortBy="#{item.name}" filterBy="#{item.name}">
          <h:outputText value="#{item.name}"/>
        </p:column>

        <p:column>
          <p:commandLink id="testButton" update=":testForm:panel" process="@this">
            <h:outputText value="Test" />
            <f:setPropertyActionListener value="#{item}" target="#{tagController.current}" />
          </p:commandLink >
        </p:column>
      </p:dataTable>
    </h:panelGroup>
  </h:form>

  <br/>

  <h:form id="testForm" styleClass="form-horizontal">
    <p:panelGrid columns="4" id="panel" >
      <h:outputLabel value="Name: #{tagController.current.name}" /> 
    </p:panelGrid>
  </h:form>

and the following backed bean:

@ViewScoped 
@Named
public class TagController implements Serializable {

  @Inject
  TagFacade tagFacade;

  protected LazyDataModel<Tag> lazyModel;
  protected ResourceBundle bundle = ResourceBundle.getBundle("resources/messages");

  @Getter
  protected Tag current = new Tag();

  public void setCurrent(Tag current) {
    System.out.println(">>>>>>>>>> THIS METHOD IS NEVER CALLED ? WHY ?");
    this.current = current;
  }

  public LazyDataModel<Tag> getLazyModel() {
  //... omitted for brevity
  }    
}

The datatable is working well, I see data, the paginator, filters and sorting works well but when I click the test link nothing happens (no exceptions, no javascript errors into the html page, no message print into stdout...).

I'm using Glassfish 3.1.2 / Mojarra 2.1.22 / PrimeFaces 3.5.

Someone can help me ?

Many thanks in advance...

¿Fue útil?

Solución

I notice that you are mixing CDI with JSF annotations. there is no view scoped annotations for CDI.you should replace view scoped with a CDI Scope or change @named annotations to @Managedbean

Otros consejos

<p:column>  
    <p:commandButton id="bb" actionListener="#{yourmanagedbean.setmyvalue(item)}" 
        title="Test" update=":testForm:panel">
    </p:commandButton>  
</p:column>

In backing bean look like this

public void setCurrent(Tag current) throws Exception {
    try {
        this.current = current;
    } catch (Exception e) {
        // ...
    }
}

Try to make panelgrid inside a panel and update it.

Since you are using annotation for getter, I suspect that by default the setter will pass directly by your variable.

You should try like this

private Tag current = new Tag();

public void setCurrent(Tag current) {
    System.out.println(">>>>>>>>>> THIS METHOD IS NEVER CALLED ? WHY ?");
    this.current = current;
}

public Tag getCurrent() {
    return this.current;
}

More info :

I had the same problem but with a different solution. I had the annotations correct and so on, but had a dialog (I didn't even use) that had the following code

<h:inputText value="#{aSBean.newElement.vaSl}" validatorMessage="Nr bitte numerisch eingeben">  
            <f:validateDoubleRange minimum="1" maximum="999" />
</h:inputText>

Somehow (still don't know why) my setter doesn't work with this piece of code in the dialog. Just adding this in case others have this problem, because it took me days to find out.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top