Re: CompoundPropertyModel and Combobox

2009-05-28 Thread Marco Santos
;
 private String usrPasswrd;
 private String usrEmail;
 private String usrMobile;
 private String usrLandline;
 private String usrFirstName;
 private String usrLastName;
 private String usrRole;
 }
 
 Hope this helps :-)
 
 cheers,
 Marcin
 
 

-- 
View this message in context: 
http://www.nabble.com/CompoundPropertyModel-and-Combobox-tp23733910p23771469.html
Sent from the Wicket - User mailing list archive at Nabble.com.


Re: CompoundPropertyModel and Combobox

2009-05-27 Thread Marcin Palka

The code below works just fine for me. Instead of using complex type as a
model object for a drop down I use an instance of IChoiceRenderer to control
what's used for an id and what's displayed as a value. 

User user = ;
setModel(new CompoundPropertyModel(user));

add(new DropDownChoice(usrRole, SystemRole.asStringList(), new
IChoiceRenderer() {

@Override
public String getDisplayValue(Object object) {
return Enum.valueOf(SystemRole.class,
object.toString()).getRoleName();
}

@Override
public String getIdValue(Object object, int index) {
if (index == -1) {
return SystemRole.SALESMAN.toString();
}
return SystemRole.asStringList().get(index);
}
}).setRequired(true));

The combo items are populated from Enum values:

public enum SystemRole {

SYS_ADMIN(Administrator systemu),
SERVICEMAN(Serwisant),
NETWORK_ADMIN(Administrator sieci),
SALESMAN(Pracownik punktu),
ANY(Bez roli);
private final String roleName;

SystemRole(String roleName) {
this.roleName = roleName;
}

public String getRoleName() {
return roleName;
}
private static ListString stringList;

public static ListString asStringList() {
if (stringList == null) {
stringList = new ArrayListString();
for (SystemRole sr : values()) {
stringList.add(sr.toString());
}
}
return stringList;
}
}

And this is how model object looks like:

public class User {
private Integer usrId;
private String usrLogin;
private String usrPasswrd;
private String usrEmail;
private String usrMobile;
private String usrLandline;
private String usrFirstName;
private String usrLastName;
private String usrRole;
}

Hope this helps :-)

cheers,
Marcin

-- 
View this message in context: 
http://www.nabble.com/CompoundPropertyModel-and-Combobox-tp23733910p23741340.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



CompoundPropertyModel and Combobox

2009-05-26 Thread Marco Santos
Hello there.
Im trying to submit a form, a simple one, that have some textfields,
checkboxes and some comboboxes (DropDownChoice class). The model of the form
is the CompoundPropertyModel which is setted like this:

setModel(new CompoundPropertyModel(userInput));

The userInput is an instance of a class that have getters and setters which
the names are the id's of the fields. When i submit the form, every field is
filled with the user input information except the fields to the comboboxes
which are empty. The dropdownchoices are instanciated like this:

= JAVA CODE =
selectedDistrito = new SelectedChoice();
distritos = new DropDownChoice(distritos, new
PropertyModel(selectedDistrito, selectedChoice), distritosModel);

= THE SELECTED CHOICE CLASS =
public class SelectedChoice implements Serializable{
private String selectedChoice = null;

/** Creates a new instance of SelectedChoice */
public SelectedChoice() {
}

public String getSelectedChoice() {
return selectedChoice;
}

public void setSelectedChoice(String selectedChoice) {
this.selectedChoice = selectedChoice;
}

}
= END OF JAVA CODE =

How can i in the CompoundPropertyModel fill the instance variables concerned
to the dropdownchoices?

Thank you very much

-- 
Marco Santos