我使用的是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...
}
我有什么选择?
Named(value="player")
注释添加到PlayerVO
类?感谢。
答案 0 :(得分:2)
为要修改的属性提供访问器应该就够了。
执行:
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}"/>