jsf 2 - How to dynamically add JSF components -
Can I add JSF components to the dynamic? I should have a form containing a button that contains a & lt; H: Input Text & gt; Is it possible to add
to the form?
I know that it should be possible in JavaScript somehow Does anyone know how to do this in JSF? I think the big problem is that I can get or set the value of new input through # {value}
.
A dynamic element such as Been ; & lt; H: dataTable & gt;
or & lt; Ui: repeat & gt;
Use & lt; H: Kickoff example with dataTable & gt;
: @ViewScoped
to make sure that the list is missed on all postbacks on the same scene.
& lt; H: form & gt; & Lt; H: Dataable value = "# {bean.it}" var = "item" & gt; & Lt; H: column & gt; & Lt; H: input text = "# {item.value}" /> & Lt; / H: column & gt; & Lt; H: column & gt; & Lt; H: command button value = "delete" action = "# {bean .remove (item)}" /> & Lt; / H: column & gt; & Lt; / H: datatable & gt; & Lt; H: command button value = "add" verb = "# {bean.ed}" /> & Lt; H: value of the command button = "save" action = "# {bean. Save}" /> & Lt; / H: form & gt;
Managed Bean:
@Menzeben @ Viewcrypted public class Bean {Private list & lt; Items & gt; item; @PostConstruct public zero init () {items = new ArrayList & lt; Items & gt; (); } Add Public Zero () {items.add (new item ()); } Remove public null (item items) {items.remove (item); } Public Zero Save () {System.out.println ("Item:" + Item); } Public listing & lt; Items & gt; GetItems () {Return Items; }}
Model:
public class items {private string value; Public string getValue () {return value; } Public Zero Set Val (string value) {this.value = value; } Public string toString () {Return string. Format ("item [value =% s]", value); See also: -
-
-
-
Li>
Comments
Post a Comment