0

Beanに@StatefulEJB があり@SessionScopedます。

私のEJB:

@Stateful
public class SomeEjb implements someEjbInterface{
    private SomeEntity entity;

    @Override
    public Boolean getEntityAssigned(){
        return entity!= null;
    }

    @Override
    public void selectEntity(String id){
        //assign entity with some values retrieved from db according to the criteria
    }
}

私のセッション スコープ Bean:

@ManagedBean
@SessionScoped
public class SessionBean{
    @EJB
    private SomeEntity entity;

    //getter and setter

    public String selectEntity(){
        entity.selectEntity(someId);
        return null;
        //Edited: if using this, no problem will occur.
        // return "index";
    }
}

マイページindex.xhtml(xmlns省略):

<h:form>
    <h:commandButton value="Select entity" action="#{sessionBean.selectEntity()}">
</h:form>
<h:link outcome="someOutcome" disabled="#{sessionBean.entity.entityAssigned}">

リンクは最初は無効になっていると思います。[エンティティの選択] をクリックすると、ejb がデータベースからエンティティを取得し、取得が成功するとリンクが有効になります。

問題は、ボタンをクリックするとリンクが壊れることです (href 属性を持つタグをレンダリングしますが、クリックする innerHtml はありません)。データを再送信せずにページをリロードした場合にのみ修正できます (フォームを再送信する F5 を使用するのではなく、URL で Enter キーを押してページを再入力します)。

エラーメッセージは次のとおりです。

HTML nesting warning on closing span: element a rendered by component : {Component-Path : some long component path refer to the link element} not explicitly closed

レンダリングを台無しにしたことを誰か知っていますか?

編集:

null の代わりに同じページの結果を返す場合、問題が存在しないことがわかりました。おそらく@ViewScoped、呼び出していた Bean を破棄しますsessionBean.selectEntity()。この違いの原因のメカニズムを説明できる人はいますか?

4

1 に答える 1