-
1. Re: Not able to get selected values from combobox
luxspes Sep 18, 2008 12:55 AM (in response to assyst)Please post here the code for your combobox in your .xhtml file.
-
2. Re: Not able to get selected values from combobox
bashan Sep 18, 2008 8:30 AM (in response to assyst)I have 2 dependent dropdowns (data is being in ajax request), and each time the father drop down is being changed and there is a ajax request, I am getting a similir error in my log.
Everything seemed to work fine beside this notification, so I decide to ignore it for now... -
3. Re: Not able to get selected values from combobox
assyst Sep 18, 2008 3:29 PM (in response to assyst)Combo box xhtml code:
<h:selectOneMenu value="#{machineBean.vendorName}">
<s:selectItems value="#{vendors}" var="vendorNm" itemLabel="#{vendorNm.vendorName}" itemValue="#{vendorNm.vendorName}" noSelectionLabel="-- Select Vendor --" />
<s:convertEntity/>
</h:selectOneMenu> -
4. Re: Not able to get selected values from combobox
assyst Sep 18, 2008 3:37 PM (in response to assyst)Please give me a sample code to get selected value from combobox(which retrieves values from database table)
-
5. Re: Not able to get selected values from combobox
assyst Sep 18, 2008 3:37 PM (in response to assyst)Please give me a sample code..
-
6. Re: Not able to get selected values from combobox
assyst Sep 18, 2008 10:21 PM (in response to assyst)I have a User Registration Form for entering user details. In this form there is one field for setting User Group,
I am able to populate the values into the combo box(from the database) but when i submit the form ,an exception occurs and i didn't get the combobox selected user group value .
Exception:
INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, bu
may not have been displayed.
sourceId = j_id10:j_id46[severity=(ERROR 2), summary=(value is required), detail
value is required)]
Please help me to solve this problem....
Combo box xhtml code:
<h:outputLabel>Group:</h:outputLabel></td>
<h:selectOneMenu name="group" id="userGroupId" value="#{userBean.userGroupId}" tabindex="4" >
<s:selectItems value="#{groups}" var="group" label="#{group.groupReferenceId}" itemValue="#{group}" noSelectionLabel="-- Select Group --" />
<s:convertEntity/>
</h:selectOneMenu>
Action Class:-
@Stateful
@Name("userAction")
@Scope(SESSION)
public class UserAction implements User, Serializable{
private GroupBean groupBean = null;
@PersistenceContext
private EntityManager em = null;
@Logger
private static Log log = null;
@DataModel
private List<GroupBean> groups = null;
@In
private transient FacesContext facesContext;
public String addUser() {
userBo = new UserBO();
groups = em.createQuery("select group from
GroupBean group").getResultList();
return "addUser";
}
@Destroy @Remove
public void destroy() {
}
}
Entity Bean:--
@Entity
@Name("groupBean")
@Scope(SESSION)
public class GroupBean implements Serializable{
private static final long serialVersionUID = 1L;
private String groupId = null;
private String groupReferenceId = null;
public GroupBean() {
}
public GroupBean(String groupId, String groupReferenceId){
this.groupId = groupId;
this.groupReferenceId = groupReferenceId;
}
@Id @GeneratedValue
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getGroupReferenceId() {
return groupReferenceId;
}
public void setGroupReferenceId(String groupReferenceId) {
this.groupReferenceId = groupReferenceId;
}
} -
7. Re: Not able to get selected values from combobox
nimo22 Sep 19, 2008 6:28 PM (in response to assyst)This:
WARNING: FacesMessage(s) have been enqueued, bu may not have been displayed. sourceId = j_id10:j_id46[severity=(ERROR 2), summary=(value is required), detail value is required)]
comes from your Validator (JSF)making these messages (
value is required
) available on client-side.This is really harmless and absolutely okay!!
You can switch it off, if you do
required="false"
<h:selectOneMenu value="#{machineBean.vendorName}" tabindex="4" required="false">
but then no validation occurs.
-
8. Re: Not able to get selected values from combobox
luxspes Sep 19, 2008 9:43 PM (in response to assyst)
nimo mayr wrote on Sep 19, 2008 18:28:
This:WARNING: FacesMessage(s) have been enqueued, bu may not have been displayed. sourceId = j_id10:j_id46[severity=(ERROR 2), summary=(value is required), detail value is required)]
comes from your Validator (JSF)making these messages (value is required
) available on client-side.
This is really harmless and absolutely okay!!
That is not true, this validation is internal at it means there is a programming error.
You can switch it off, if you dorequired="false"
<h:selectOneMenu value="#{machineBean.vendorName}" tabindex="4" required="false">
but then no validation occurs.
Again not true, required="false" is only to force you to select something, not to
turn off internal validation.Click HELP for text formatting instructions. Then edit this text and check the preview.
-
9. Re: Not able to get selected values from combobox
luxspes Sep 19, 2008 9:59 PM (in response to assyst)Well, first of all if your GroupBean is an @Entity shouldn't have this:
@Name("groupBean") @Scope(SESSION)
Last time I had this kind of problem it was because the properties binded by the selectOneMenu had the wrong ScopeType:
<h:selectOneMenu name="group" id="userGroupId" value="#{userBean.userGroupId}" tabindex="4" > <s:selectItems value="#{groups}" var="group" label="#{group.groupReferenceId}" itemValue="#{group}" noSelectionLabel="-- Select Group --" /> <s:convertEntity/> </h:selectOneMenu>
#{userBean.userGroupId} should be stored in ScopeType.PAGE (or ScopeType.SESSION, but PAGE is better most of the times), something like:
@In(required = false, scope = ScopeType.PAGE) @Out(required = false, scope = ScopeType.PAGE) private String userGroupId;
But I haven't tried that with a String, in my code I prefer to use the Bean directly
@In(required = false, scope = ScopeType.PAGE) @Out(required = false, scope = ScopeType.PAGE) private GroupBean userGroup;
and
<h:selectOneMenu name="group" id="userGroupId" value="#{userBean.userGroup}" tabindex="4"> <s:selectItems value="#{groups}" var="group" label="#{group.groupReferenceId}" itemValue="#{group}" noSelectionLabel="-- Select Group --" /> <s:convertEntity/> </h:selectOneMenu>
Your other problem may be #{group} it might be get empty some times (you shoul be using @Factory or a getter getGroup() that makes the query and only uses the group variable as cache.
Hope this helps,
-
10. Re: Not able to get selected values from combobox
luxspes Sep 19, 2008 10:04 PM (in response to assyst)Ups, I misread, my mistake, you are right, sorry,sorry,sorry. (But I still think the code posted by the original poster has many mistakes)