-
1. Re: Simple dropdown
jamesjmp Sep 23, 2008 7:03 PM (in response to jaand96)a couple of things:
- is there any exception in the log?
- have you defined setter and getter methods for term? Maybe it´s just a wrong typing problem. if you use#{Dummy.term}
you should have a getter and setter for a property called exactly term.
I advise you to trace your setter / getter methods of the property where you want to store that value.
hope it helps -
2. Re: Simple dropdown
nimo22 Sep 23, 2008 10:13 PM (in response to jaand96)Why do you want to get a selected Item with a @DataModel(Selection)?
Normally you only need to check the value of your Dummy.term !
When you select an item of allterm, then the selected value is IN your term.
Your term should have following form:
private Terminal term; //getters/setters of term
change your choose-Method:
System.out.println("TERMINAL:" + this.getTerm());
That should be work!
-
3. Re: Simple dropdown
bhiles Sep 24, 2008 12:36 AM (in response to jaand96)I only suggest this because I once spent several hours troubleshooting a problem like this... and then promptly chastising myself for not thinking of it. Are your form fields in your .xhtml in a h:form? If it isn't in a form, it won't get sent through to the server.
-
4. Re: Simple dropdown
jaand96 Sep 24, 2008 1:05 PM (in response to jaand96)Thanks for replies!
I had getters/setters and the h:form tag so that was not the problem. By way of experimentation I finally got it to work.
I did two things:
Removed the @DataModelSelection from the terminal field.
Changed s:button to h:commandButton.To be honest I can't say either of these things makes sense to me. However it works now so I'm happier. But if someone has more info on this that would be great.
cheers
-
5. Re: Simple dropdown
nimo22 Sep 24, 2008 3:12 PM (in response to jaand96)As I said:
Why do you want to get a selected Item with a @DataModelSelection?You do not need it for a simple selection via selectOneMenu.
-
6. Re: Simple dropdown
valatharv Oct 14, 2008 6:01 AM (in response to jaand96)Hi,
Please suggest what should be changed in order to get it working.
Scenario :
I have 2 dropdowns, value of second is dependent on 1st.
Like if user selects "Item 1" from 1st. dropdown, 2nd. dropdown should display A,B,C
If user selects "Item 2" from 1st. dropdown, 2nd. dropdown should display D,E,F and
If user selects "Item 3" from 1st. dropdown, 2nd. dropdown should display G,H,I
Note : Both drop downs are is SEPARATE panel. (If I use the code in same panel it works, however as per requirement
it should be in different panel)
Issues & sequence of events:
a) When the page loads, default value in dropdown 1 is "select ..."(it have list as Item 1, Item 2, Item 3) and 2nd. dropdown is null.. OK
b) When I select any Item, I think onchange event is not fired and nothing happens, no error in log, 2nd. dropdown still null.
c) If I select say "Item 2" and refresh the page 2nd. dropdown gets populated with "D, E, F"
d) If I try to select any value in 1st. drop-down, message is displayed as
WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=listItraq:j_id26[severity=(ERROR 2), summary=(value is not valid), detail=(value is not valid)]
.......
Please suggest...
xhtml
-----
<h:form id="listItems">
<rich:panel>
<a:outputPanel id="myPanel">
<h:selectOneMenu value="#{itemList.masterValue}">
<s:selectItems var="v_item" value="#{itemList.masterItems}" label="#{v_item}" noSelectionLabel="select ..."/>
<a:support event="onchange" reRender="myPanel"></a:support>
</h:selectOneMenu>
</a:outputPanel>
</rich:panel>
<rich:panel>
<a:outputPanel>
<h:selectOneMenu value="#{itemList.detailValue}">
<s:selectItems var="v_item" value="#{itemList.detailItems}" label="#{v_item}" />
</h:selectOneMenu>
</a:outputPanel>
</rich:panel>
</h:form>
Bean class:
-----------
@Name("itemList")
@Stateless
public class ItemListBean implements ItemListLocal {
private String masterValue;
private String detailValue;
public List<String> getDetailItems() {
ArrayList<String> result = new ArrayList<String>();
System.out.println("Master value is ="+masterValue);
if (masterValue != null) {
if (masterValue.equalsIgnoreCase("Item 1")) {
result.add("A");
result.add("B");
result.add("C");
}
if (masterValue.equalsIgnoreCase("Item 2")) {
result.add("D");
result.add("E");
result.add("F");
}
if (masterValue.equalsIgnoreCase("Item 3")) {
result.add("G");
result.add("H");
result.add("I");
}
}
return result;
}
public String getDetailValue() {
return detailValue;
}
public List<String> getMasterItems() {
ArrayList<String> result = new ArrayList<String>();
result.add("Item 1");
result.add("Item 2");
result.add("Item 3");
return result;
}
public String getMasterValue() {
return masterValue;
}
public void setDetailValue(String detailValue) {
this.detailValue = detailValue;
}
public void setMasterValue(String masterValue) {
this.masterValue = masterValue;
}
} -
7. Re: Simple dropdown
mail.micke Oct 14, 2008 2:25 PM (in response to jaand96)<rich:panel> <a:outputPanel id="myPanel"> <h:selectOneMenu value="#{itemList.masterValue}"> <s:selectItems var="v_item" value="#{itemList.masterItems}" label="#{v_item}" noSelectionLabel="select ..."/> <a:support event="onchange" reRender="panel2"></a:support> </h:selectOneMenu> </a:outputPanel> </rich:panel> <rich:panel id="panel2"> <a:outputPanel rendered="#{!empty itemList.masterValue}"> <h:selectOneMenu value="#{itemList.detailValue}"> <s:selectItems var="v_item" value="#{itemList.detailItems}" label="#{v_item}" /> </h:selectOneMenu> </a:outputPanel> </rich:panel> </h:form>
You needed to reRender the the second panel when the value in the first dropdown is changed.
Also you might want to put the population of the detail values inside a valueChange listener for the first dropdown instead of having it in the getter.
Hope this helps,
Micke -
8. Re: Simple dropdown
joblini Oct 14, 2008 6:40 PM (in response to jaand96)The message you reported
WARNING: FacesMessage(s) have been enqueued, but may not have been displayed. sourceId=listItraq:j_id26[severity=(ERROR 2), summary=(value is not valid), detail=(value is not valid)]
Indicates that the current value is not in the list of Select Items. View the generated HTML source code to see what value attributes are being generated for the Select Items. You may need to use a converter, for example, the <s:convertEntity> tag.
-
9. Re: Simple dropdown
dustismo Oct 14, 2008 7:38 PM (in response to jaand96)I'm surprised that nobody picked this up:
s:button does not submit the form
h:commandButton is what you wanted.
best,
Dustin -
10. Re: Simple dropdown
valatharv Oct 14, 2008 8:14 PM (in response to jaand96)First of al thanks alot for nice suggestions....
I am not sure what is happening with the dropdowns.... to some extent it is fine but issue is there...
1st. dropdown displays selected value as "Item 1" and 2nd. dropdown list "A,B,C".
When I select "Item 2" and 2nd. dropdown list "D,E,F", it looks ok till now.
Issue:
However if I refresh the page and select "Item 1" (in 1st. dropdown), 2nd. dropdown values do not change to "A, B, C" from "D, E, F" and displays error as "value is not valid".... and if I select "Item 2" the cycle works fine...
xhtml code:
-----------
<rich:panel>
<a:outputPanel id="myPanel">
<s:decorate id="masterItems" template="layout/edit.xhtml">
<ui:define name="label">Master Items : </ui:define>
<h:selectOneMenu value="#{itemList.masterValue}" required="true">
<s:selectItems var="v_item" value="#{itemList.masterItems}" label="#{v_item}"/>
<!--<s:convertEntity/>-->
<a:support event="onchange" reRender="panel2"></a:support>
</h:selectOneMenu>
</s:decorate>
</a:outputPanel>
</rich:panel>
<rich:panel id="panel2">
<a:outputPanel rendered="#{!empty itemList.masterValue}">
<s:decorate id="detailItems" template="layout/edit.xhtml">
<ui:define name="label">Detail Items : </ui:define>
<h:selectOneMenu value="#{itemList.detailValue}">
<s:selectItems var="v_item" value="#{itemList.detailItems}" label="#{v_item}"/> </h:selectOneMenu>
</s:decorate>
</a:outputPanel>
</rich:panel>