Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
I am creating a web application, where you have to read a list of objects / entities from a DB and populate it in a JSF <h:selectOneMenu>. I am unable to code this. Can someone show me how to do it? I know how to get a List<User> from the DB. What I need to know is, how to populate this list in a <h:selectOneMenu>. <h:selectOneMenu value="#{bean.name}"> ...? </h...
I am using the managedBean userHome in requestScope, in which the entity 'user' is going to be persist. The user has the leader column which is mapped in ManyToOne relation.My Code looks like this @ManagedBean @RequestScoped public class UserHome { private User user = new User(); // Getters and Setters private List<SelectItem> selectItems = new ArrayList<SelectItem>...
I want to fill a selectonemenu but always I have this error : java.lang.String cannot be cast to javax.faces.model.SelectItem this is the code: public class ToolsJIRA implements Serializable{ private String myChoicePeriod; //getters and setters } JSF: <h:selectOneMenu value="#{ToolsJIRA.myChoicePeriod}"> <f:selectItem itemValue="Month" value="Month"/> ...
I have a combo in my page which I want to have populated with some keywords from configuration. I want to use a managed bean to accomplish it. Let's say that I have a bean called Config, where there is a List categories field. .. public class Configuration implements Serializable { private static final long serialVersionUID = 1L; private List<String> categories; public List...
Is it possible to have objects as itemValue in tag? for example I have a class Foo: public class Foo { private int id; private String name; private Date date; } And another class Bar public class Bar { private Foo foos; } public class BarBean { private Set<Foo> foos; } Now in a Bean called BarBean I need to have a to get the Foo of the current Bar from User like this: ...
I am using JSF tag h:selectOneMenu for a drop down List. <h:selectOneMenu id="subscriberName" value="#{manageSubscriberInformation.subscriberName}" <f:selectItem itemValue="" itemLabel="" /> <f:selectItems value="#{manageSubscriberInformation.subList}" /> </h:selectOneMenu> The subList object is a list which I have defined in my bea...
I can't populate a JSF combo box with predefined data from a Java collection. Backend, simple stub for collection: PriceRecord pr = new PriceRecord(); pr.setTypeCode(Arrays.asList(123L,456L)); This doesn't work, the combo box remains empty: <h:selectOneMenu value="#{price.typeCode}" var="code"> <f:selectItem value="#{code}"/> </h:selectOneMenu>
I have a problem in populaing dropdown value based on ID. View: <h:selectOneMenu id="dropDown" value="#{sampleVo.dropDownType}" "> <f:selectItem itemValue="Select Value" itemLabel="Select Value" /> <f:selectItems value="#{sampleService.dropDownList}" /> </h:selectOneMenu> SampleVo: public class SampleVo implements Serializable { private String dropDown...
If I want to add passThroughAttributes to some of the options of a select-element I can use f: passThroughAttribute as child-component of f:selectItem. But normally I'm using a List of SelectItems to generate the options. In contrast to UiComponent SelectItem does not have a method getPassThroughAttributes. Anybody knows a reason why?
I'm new to facelets and I have generated a project using netbeans but I struggling with the tag. I have <h:selectOneMenu id="country" value="#{organisation.organisation.country}" title="Country" > <f:selectItems value="#{country.countryItemsAvailableSelectOne}"/> </h:selectOneMenu> In the select I get classpath.Country[iso=GB] which I can see ...
I have to display a list box with label as value "name" & I am using h:selectOneListbox. My Code is : <h:selectOneListbox id="select" value"#{trial.trials}" size="1" title="Select Item..."> <f:selectItems value="#{trial.trials}/> </h:selectOneListbox> My trial bean is : public class trial{ List<trialDataBean> trials = new ArrayList<trialDataBean>(); p...
I have asked this question several times in this and various other forums, but still unable to implement it in my code. I am doing this example , and i need to add a listbox (like in the column MANUFACTURE). i am unable to display the Listbox or populate it with values from my Java class. My java code looks like this; private List<Hotel> listHotel; public List<Hotel> ListAllHo...
I have an ArrayList named as AddressList and I want to convert it to an ArrayList .I have tried the below In addressbean private String addressSelected; private List<SelectItem> addresslList = new ArrayList<SelectItem>(); I got the exception when i called the below to fetch the addressList1 from DB addresslList = GenerateAddressDAO.getAddressList(); getAddressList...
I have 5 radio buttons in my form, selecting one and proceeding takes me to a form that the user need to fill up. Now out of these 5, I have not yet finished 2 of the forms that these radio buttons take me. So I wanted to disable the radio buttons which donot have the forms ready. How I solve it now: if a user selects one of these radio buttons that donot have a form ready, it says "Page unde...
I have created a SelectOneMenu uicomponent SelectOneMenu value = new SelectOneMenu(); I want to insert some selectItems in the SelectOneMenu. I tried this String[] options = question.getOptions().split(","); for(String option : options){ SelectItem selectItem = new SelectItem(); selectItem.setLabel(option); selectItem.setValue(option); value.getChildren().add(selectItem); } ...
Is it possible to write a custom filter for a datatable? I want to filter the data regarding the property status_flag. This status_flag can have following values: available, enable, disabled. I need a filter method which shows me either the total list or the total list without the disabled.
I have LinkedHashMap<String,List<SelectItem>> results = got the results from DB see here I need to assign the above results to the lists available in UI using for loop. for (Map.Entry<String, List<SelectItem>> entry : results.entrySet()) { String key = entry.getKey(); List<SelectItem> values = entry.getValue(); System.out.println("Key = " ...
I'm trying to create a dropdown box in JSF. It needs to be filled with numbers within a given valid range. So example if the given range is between 5 and 20 than the dropdown values should be; "5, 10 15, 20" I have some problems, In my controller I create something like this and set values with a for loop; List<Integer> validAmounts OR List<String> validAmounts Then &l...
I have a List <Hotel> object and I need to save it to a SelectItem[] object. How do I code this? public List <Hotel> hotel; public SelectItem[] food; // followed by getters and setters I need to save the hotel object to a food object. How do I code this in Java?
I have created entites and facde in netbeans. Now I want to create a native query to get only two feilds from the table. And then Bind them to the String query = "SELECT DISTINCT(m.idManufacturer),m.hmid " + " FROM model m"; @SuppressWarnings("unchecked") List<model> modelList = (List&lt;model>) getEntityManager().createNativeQuery(query).getResultList(); and t...
in my ApplicationBean1.java class I have an Option[] attribute years and a filling method: public void buildYearOptions(){ int initialYear = 1900; int currentYear = Calendar.getInstance().get(Calendar.YEAR); int i = 0; for (int y = initialYear; y< currentYear; y++){ Option op = new Option(y, Integer.toString(y)); years[i] = op; i++; } } ...
  /*
   * $Id: SelectItem.java,v 1.17 2007/04/27 22:00:10 ofung Exp $
   */
  
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   * 
   * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
   * 
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
  * and Distribution License("CDDL") (collectively, the "License").  You
  * may not use this file except in compliance with the License. You can obtain
  * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
  * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  * 
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
  * Sun designates this particular file as subject to the "Classpath" exception
  * as provided by Sun in the GPL Version 2 section of the License file that
  * accompanied this code.  If applicable, add the following below the License
  * Header, with the fields enclosed by brackets [] replaced by your own
  * identifying information: "Portions Copyrighted [year]
  * [name of copyright owner]"
  * 
  * Contributor(s):
  * 
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 package javax.faces.model;
 
 

SelectItem represents a single item in the list of supported items associated with a javax.faces.component.UISelectMany or javax.faces.component.UISelectOne component.

 
 
 public class SelectItem implements Serializable {
 
     private static final long serialVersionUID = 876782311414654999L;
 
 
     // ------------------------------------------------------------ Constructors
 

    

Construct a SelectItem with no initialized property values.

 
     public SelectItem() {
 
         super();
 
     }


    

Construct a SelectItem with the specified value. The label property will be set to the value (converted to a String, if necessary), the description property will be set to null, the disabled property will be set to false, and the escape property will be set to ( true.

Parameters:
value Value to be delivered to the model if this item is selected by the user
 
     public SelectItem(Object value) {
 
         this(valuevalue == null ? null : value.toString(), nullfalsetrue);
 
     }


    

Construct a SelectItem with the specified value and label. The description property will be set to null, the disabled property will be set to false, and the escape property will be set to true.

Parameters:
value Value to be delivered to the model if this item is selected by the user
label Label to be rendered for this item in the response
    public SelectItem(Object valueString label) {
        this(valuelabelnullfalsetrue);
    }


    

Construct a SelectItem instance with the specified value, label and description. This disabled property will be set to false, and the escape property will be set to true.

Parameters:
value Value to be delivered to the model if this item is selected by the user
label Label to be rendered for this item in the response
description Description of this item, for use in tools
    public SelectItem(Object valueString labelString description) {
        this(valuelabeldescriptionfalsetrue);
    }


    

Construct a SelectItem instance with the specified property values. The escape property will be set to true.

Parameters:
value Value to be delivered to the model if this item is selected by the user
label Label to be rendered for this item in the response
description Description of this item, for use in tools
disabled Flag indicating that this option is disabled
    public SelectItem(Object valueString labelString description,
                      boolean disabled) {
        this(valuelabeldescriptiondisabledtrue);
    }
    
    

Construct a SelectItem instance with the specified property values.

Parameters:
value Value to be delivered to the model if this item is selected by the user
label Label to be rendered for this item in the response
description Description of this item, for use in tools
disabled Flag indicating that this option is disabled
escape Flag indicating that the text of this option should be escaped when rendered.
Since:
1.2
    public SelectItem(Object valueString labelString description,
                      boolean disabledboolean escape) {
        super();
        setValue(value);
        setLabel(label);
        setDescription(description);
        setDisabled(disabled);
        setEscape(escape);
    }
    
    // ------------------------------------------------------ Instance Variables
    private String description = null;
    private boolean disabled = false;
    private String label = null;
    @SuppressWarnings({"NonSerializableFieldInSerializableClass"})
    private Object value = null;
    // -------------------------------------------------------------- Properties


    

Return a description of this item, for use in development tools.

    public String getDescription() {
        return (this.);
    }


    

Set the description of this item, for use in development tools.

Parameters:
description The new description
    public void setDescription(String description) {
        this. = description;
    }


    

Return the disabled flag for this item, which should modify the rendered output to make this item unavailable for selection by the user if set to true.

    public boolean isDisabled() {
        return (this.);
    }


    

Set the disabled flag for this item, which should modify the rendered output to make this item unavailable for selection by the user if set to true.

Parameters:
disabled The new disabled flag
    public void setDisabled(boolean disabled) {
        this. = disabled;
    }


    

Return the label of this item, to be rendered visibly for the user.

    public String getLabel() {
        return (this.);
    }


    

Set the label of this item, to be rendered visibly for the user.

Parameters:
label The new label
    public void setLabel(String label) {
        this. = label;
    }


    

Return the value of this item, to be delivered to the model if this item is selected by the user.

    public Object getValue() {
        return (this.);
    }


    

Set the value of this item, to be delivered to the model if this item is selected by this user.

Parameters:
value The new value
    public void setValue(Object value) {
        this. = value;
    }

    
Holds value of property escape.
    private boolean escape;

    
Getter for property escape.

Returns:
Value of property escape.
    public boolean isEscape() {
        return this.;
    }

    
Setter for property escape.

Parameters:
escape New value of property escape.
    public void setEscape(boolean escape) {
        this. = escape;
    }
New to GrepCode? Check out our FAQ X