如何访问托管 Bean 中的对象?

How to access an object that is in a Managed Bean?

我正在使用 JSF 2.2。

例如,我有一个表格:

<section class="form-group">
    <input type="text" class="flat-textbox" id="names" placeholder="Nombres"/>
</section>
<section class="form-group">
    <input type="text" class="flat-textbox" id="surnames" placeholder="Apellidos"/>
</section>
<section class="form-group">
    <input type="datetime" class="flat-textbox" id="birth-date" 
           placeholder="F. Nacimiento"/>
</section>

我想用每个输入绑定播放器:

<input type="text" class="flat-textbox" id="names"
       jsf:value="#{playerbean.player.names} placeholder="Nombres"/>

豆子是:

@Named(value="playerbean")
@RequestScoped
public class PlayerBean {
    @Inject private PlayerServiceImpl playerService;
    @Inject private PlayerVO player; // i want set properties from view form

    // methods...
}

我有什么选择?

谢谢。

为您要修改的 属性 提供访问器应该就足够了。

做:

public PlayerVO getPlayer() { return player; }
public void setPlayer(PlayerVO player) { this.player = player; }

和:

<input type="text" class="flat-textbox" 
       id="names" jsf:value="#{playerbean.player.names}"/>