-
1. Re: rich:select not working correctly rerender
iabughosh Feb 13, 2012 4:25 AM (in response to v2adam)Hello Adam,
could you follow these steps:
1-move h:form from your popup panel to outside ex:
<h:form id="yourPanelForm">
<rich:popupPanel>
...
</rich:popupPanel>
</h:form>
2-add domAttachmentElement="form" to your popup panel.
<rich:popupPanel domAttachmentElement="form">
....
regards,
-
2. Re: rich:select not working correctly rerender
v2adam Feb 13, 2012 9:02 AM (in response to iabughosh)Thank for your replied, but it not help.
Before press button, all work fine, in your version, as in me, but after press button and call "Validation Error: Value is required.",
all stop working, correct rerender.
My action:
1. Open panel
2. Press button (execute valid error)
3. Close panel
4. Open panel
5. Try to select each item in first rich:select, and you will see second rich:select not correct rerender.
My test code:
import java.util.ArrayList; import java.util.List; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; import javax.faces.event.AjaxBehaviorEvent; import javax.faces.model.SelectItem; @ManagedBean(name="test") @ViewScoped public class Test { private List<SelectItem> selectItem1 = new ArrayList<SelectItem>(); private List<SelectItem> selectItem2 = new ArrayList<SelectItem>(); private List<SelectItem> choice1 = new ArrayList<SelectItem>(); private List<SelectItem> choice2 = new ArrayList<SelectItem>(); private String selected1; private String selected2; private String text; public Test() { selectItem1.add(new SelectItem("Object1","String1")); selectItem1.add(new SelectItem("Object2","String2")); selectItem1.add(new SelectItem("Object3","String3")); selectItem1.add(new SelectItem("Object4","String4")); choice1.add(new SelectItem("Object11","String11")); choice1.add(new SelectItem("Object22","String22")); choice1.add(new SelectItem("Object33","String33")); choice1.add(new SelectItem("Object44","String44")); choice2.add(new SelectItem("Object111","String111")); choice2.add(new SelectItem("Object222","String222")); choice2.add(new SelectItem("Object333","String333")); choice2.add(new SelectItem("Object444","String444")); selected1 = selectItem1.get(0).getValue().toString(); } public void listener(AjaxBehaviorEvent event){ if("Object2".equals(selected1)){ selectItem2.clear(); selectItem2.addAll(choice1); }else if("Object4".equals(selected1)){ selectItem2.clear(); selectItem2.addAll(choice2); }else{ selectItem2.clear(); } if(!selectItem2.isEmpty()) selected2 = selectItem2.get(0).getValue().toString(); } public String click(){ System.out.println(">>>>>>>>>>>>>>>>click"); return null; } public List<SelectItem> getSelectItem1() { return selectItem1; } public void setSelectItem1(List<SelectItem> selectItem1) { this.selectItem1 = selectItem1; } public List<SelectItem> getSelectItem2() { return selectItem2; } public void setSelectItem2(List<SelectItem> selectItem2) { this.selectItem2 = selectItem2; } public String getSelected1() { return selected1; } public void setSelected1(String selected1) { this.selected1 = selected1; } public String getSelected2() { return selected2; } public void setSelected2(String selected2) { this.selected2 = selected2; } public String getText() { return text; } public void setText(String text) { this.text = text; } }
<h:form> <a4j:commandButton value="open" oncomplete="#{rich:component('popup')}.show();" render="panel"/> </h:form> <h:form> <rich:popupPanel id="popup" modal="true" onmaskclick="#{rich:component('popup')}.hide();" domElementAttachment="form"> <f:facet name="header"> <h:outputText value="Title" /> </f:facet> <a4j:outputPanel id="panel"> <rich:select id="select" value="#{test.selected1}" enableManualInput="false"> <f:selectItems value="#{test.selectItem1}"/> <a4j:ajax event="selectitem" execute="@this" listener="#{test.listener}" render="select2"/> </rich:select> <br/> <rich:select value="#{test.selected2}" enableManualInput="false" id="select2" defaultLabel="no items"> <f:selectItems value="#{test.selectItem2}"/> </rich:select> <br/> <br/> <rich:message for="text"/> <br/> <h:inputText value="#{test.text}" required="true" id="text"/> <br/> <br/> <a4j:commandButton value="click" /> </a4j:outputPanel> </rich:popupPanel> </h:form>
-
3. Re: rich:select not working correctly rerender
v2adam Feb 14, 2012 1:37 AM (in response to v2adam)People who have suggestions
-
4. Re: rich:select not working correctly rerender
v2adam Feb 14, 2012 7:06 AM (in response to v2adam)1 of 1 people found this helpfulFor myself, i found only one solution, used different form for rich:select and h:inputText
with attribute required="true" or remove attribute and call from class validation error.
-
5. Re: rich:select not working correctly rerender
friednail Jun 21, 2012 11:45 AM (in response to v2adam)1 of 1 people found this helpfulI have the same problem:
If i have any validation error on page, then selected label for rich:select resets to default. Note: resets only label, value is still what i have set.
It's happening because in f:selectItems stored Objects, but after validation error and rerender in selectedItem value we have String (submittedValue is null). Thats matters when we get selectedLabel on rerender.
See
org.richfaces.renderkit.SelectHelper.java line 126
for understanding the problem.
I can advise you two ways of workaround:
1. Check that in every SelectItem you use String objects as value
2. Override org.richfaces.SelectRenderer
Hope it will help, after all i'm novice.