Hello everybody,
I want to have a field, named Country, into my form , and the user must select between 3 countries (Spain, Italy, France) !
I want to do that with the multiple choice list (like the font size field into the editor). I don't know how to do it with primefaces cause I am new !
Thanks for helping me !
the multiple choice list problem
T tried to follow this tuto :
http://www.primefaces.org/showcase-labs ... Column.jsf
I make something like this (in my classBean):
and in mypage.xhtml:
When I execute, I got this error:
What should I do
http://www.primefaces.org/showcase-labs ... Column.jsf
I make something like this (in my classBean):
Code: Select all
static {
countries = new String[3];
countries [0] = "France";
countries [1] = "Italy";
countries [2] = "Spain";
}
private final static String[] countries;
Code: Select all
<h:outputLabel value="Country:" />
<h:selectOneMenu >
<f:selectItems value="#{userController.countries}" var="country" itemLabel="#{user}" itemValue="#{user}" />
</h:selectOneMenu>
Code: Select all
value="#{userController.countries}": The class 'jpa.controllers.UserController' does not have the property 'countries'.
What should I do
Hi,
<h:selectOneMenu> can not be empty without attributes. You should define value="#{....}" for (pre)selected value.
<h:selectOneMenu> can not be empty without attributes. You should define value="#{....}" for (pre)selected value.
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
OK, I edit it like this:
The error message had disappeared, but the output of the country field is empty ... I mean I got nothing in front of "Country:" in my page
Code: Select all
<h:selectOneMenu value="#{userController.selectedUser.country}" rendered="#{userController.editMode}">
<f:selectItems value="#{userController.countries}" var="country" itemLabel="#{user}" itemValue="#{user}" />
</h:selectOneMenu>
-
- Posts: 5
- Joined: 06 Aug 2011, 04:11
hmmm....
value="#{userController.countries} , here "countries" refers to an ArrayList.
Then,You should have a method called in any moment which load your ArrayList named "countries"!
Your method "loadArrayListCountries" can be called in the Constrctor of your backBean .
http://www.primefaces.org/showcase/ui/d ... eBasic.jsf
public class UserController{
List countries;
public userController() { //This is the Constrctor of your backBean .
countries= new ArrayList<Countries>();
loadArrayListCountries();
}
private void loadArrayListCountries() {
// get Countries from Database!
}
}
CASTLEROCK
value="#{userController.countries} , here "countries" refers to an ArrayList.
Then,You should have a method called in any moment which load your ArrayList named "countries"!
Your method "loadArrayListCountries" can be called in the Constrctor of your backBean .
http://www.primefaces.org/showcase/ui/d ... eBasic.jsf
public class UserController{
List countries;
public userController() { //This is the Constrctor of your backBean .
countries= new ArrayList<Countries>();
loadArrayListCountries();
}
private void loadArrayListCountries() {
// get Countries from Database!
}
}
CASTLEROCK
-
- Information
-
Who is online
Users browsing this forum: No registered users and 30 guests