I have a <p:selectManyCheckbox> element which has a rendered attribute inside a dynaform.
When I save the form the selected items in the <p:selectManyCheckbox> are not set.
When I remove the rendered attribute it works perfectly.
My environment : Wildfly 8.2, java 1.8, Primefaces 5.1 and Primefaces extension 3.0.0
My example below
XHTML
<h:form id="form">
<p:commandButton value="save" action="#{testController.onSave}"></p:commandButton>
<pe:dynaForm id="dynaForm" value="#{testController.dynaFormModelTest}" var="field" autoSubmit="false" buttonBarPosition="both" widgetVar="dynaFormVar">
<!-- LABEL -->
<pe:dynaFormControl>
<h:outputText value="#{field.label}" />
</pe:dynaFormControl>
<!-- TYPE DE CHAMPS -->
<!-- CHOIX MULTIPLE -->
<pe:dynaFormControl type="multi_select">
<p:selectManyCheckbox value="#{field.selectedValues}" layout="grid" columns="1"
rendered="#{field.canSelectMultipleValues}">
<f:selectItems value="#{field.values}" var="l" itemLabel="#{l}" itemValue="#{l}"/>
</p:selectManyCheckbox>
</pe:dynaFormControl>
</pe:dynaForm>
</h:form>
Bean
@Named
@ViewScoped
public class TestController implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
FormModelSouscription formSouscription;
private DynaFormModel dynaFormModelTest;
@PostConstruct
public void init() {
initDynaFormModel();
}
private void initDynaFormModel() {
dynaFormModelTest = new DynaFormModel();
Field field = new Field();
field.setLabel("Lialbilities");
field.setCanSelectMultipleValues(true);
field.setValues(Arrays.asList("Other", "Loans", "Debts"));
DynaFormRow row = dynaFormModelTest.createRegularRow();
DynaFormLabel label = row.addLabel(field.getLabel());
DynaFormControl control = row.addControl(field, "multi_select");
label.setForControl(control);
}
public void onSave() {
for (DynaFormControl control : dynaFormModelTest.getControls()) {
Field field = (Field) control.getData();
System.out.println(field.getSelectedValues());
}
}
public DynaFormModel getDynaFormModelTest() {
return dynaFormModelTest;
}
public void setDynaFormModelTest(DynaFormModel dynaFormModelTest) {
this.dynaFormModelTest = dynaFormModelTest;
}
}
Field Model
public class Field {
String label;
List<String> values;
List<String> selectedValues;
boolean canSelectMultipleValues;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public List<String> getValues() {
return values;
}
public void setValues(List<String> values) {
this.values = values;
}
public List<String> getSelectedValues() {
return selectedValues;
}
public void setSelectedValues(List<String> selectedValues) {
System.out.println("set selected values");
this.selectedValues = selectedValues;
}
public boolean isCanSelectMultipleValues() {
return canSelectMultipleValues;
}
public void setCanSelectMultipleValues(boolean canSelectMultipleValues) {
this.canSelectMultipleValues = canSelectMultipleValues;
}
}
Thanks for your answers
ManyCheckbox with rendered attribute in Dynaform not working
Ich will check that before the upcoming release 3.1.0 (soon). Thanks for reporting.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin
-
- Information
-
Who is online
Users browsing this forum: No registered users and 20 guests