开发者

jsp TextField binding

I have a panel in my Page1.jsp:

<webuijsf:panelLayout binding="#{Page1.dynamicFieldsPanel}"
    id="dynamicFieldsPanel" -rave-layout: grid"/>

Then I have this in Page1.java:

private PanelLayout dynamicFieldsPanel = new PanelLayout();

public void setDynamicFieldsPanel(PanelLayout pl)
{
    this.dynamicFieldsPanel = pl;
}

public PanelLayout 开发者_如何学PythongetDynamicFieldsPanel()
{
    TextField textField = new TextField();
    this.dynamicFieldsPanel.getChildren().add(textField);

    return dynamicFieldsPanel;
}

How do I bind my dynamic TextField to something so I can retrieve the value entered by the user?


You need to create a value binding which binds the component's value with some bean property. Since you're using the (over 3 years dead and abandoned) Woodstock library I bet that you're still on the legacy JSF 1.1, so here's a JSF 1.1 targeted example:

FacesContext context = FacesContext.getCurrentInstance();
ValueBinding value = context.getApplication().createValueBinding("#{bean.property}");
someComponent.setValueBinding("value", value);

The #{bean.property} should of course point to a valid and existing property in the managed bean #{bean}. If the amount or names are unpredictable beforehand, then you may consider to use a Map property for this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜