0

呼び出したときに PrimeFaces ビューで理由がわかりません

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

バッキング Bean の tagController.setCurrent メソッドを呼び出すことはありません。

私は次の見解を持っています:

  <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>

および次のバッキング 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
  }    
}

データテーブルはうまく機能しています。データ、ページネーター、フィルター、および並べ替えはうまく機能していますが、テスト リンクをクリックしても何も起こりません (例外、HTML ページへの JavaScript エラー、stdout へのメッセージ出力はありません...)。

Glassfish 3.1.2 / Mojarra 2.1.22 / PrimeFaces 3.5 を使用しています。

誰かが私を助けることができますか?

よろしくお願いします...

4

4 に答える 4

1

CDI と JSF アノテーションが混在していることに気付きました。CDI のビュー スコープ アノテーションはありません。ビュー スコープを CDI スコープに置き換えるか、@named アノテーションを @Managedbean に変更する必要があります。

于 2013-06-08T14:32:42.017 に答える
0

ゲッターに注釈を使用しているため、デフォルトではセッターが変数を直接渡すと思われます。

あなたはこのように試してみるべきです

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;
}

より詳しい情報 :

于 2013-06-07T21:45:17.130 に答える