-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I have used zeta form to build a web application.
For that, I created two tables : Reparation and Vehicule (where idvehicule is a foreign key in table reparation).
Everything works great , I can edit, save, delete a reparation. The only things that I couldn't do is assign a default value to the lisbox vehicule.
So If the first element is selected , I get the error: org.hibernate.PropertyValueException: not-null property references a null or transient value: gestion.reparation.base.Reparation.id_vehicule
This is a part of my zul file:
<row>Vehicule :<listbox rows="1" mold="select" id="vehicule_id_vehicule" onCreate="vehicule_id_vehicule.setSelectedIndex(-1)" model="@{vehiculeModel.all}"
selectedItem="@{reparationModel.selected.vehicule_id_vehicule,save-when=none}" >
<listitem self="@{each=zx10}"><listcell label="@{zx10.imma_vehicule}"/></listitem>
</listbox></row>
I would really appreciate your help
It's a selected item not a selected property! So the selectedItem gives back the domain bean
selectedItem="@{reparationModel.selected.vehicule,...
If you need the id from them you must get the bean in your controller and read out the property for it.
Vehicle vehicle = (Vehicle) getListbox().getSelectedItem(); int id = vehicle.getId();
best
Stephan
Hi,
Could you please tell me what change need to be made so that I can add a new listitem "Select Vehicule" as the first element of my listbox.
and the others are the listitems created from databinding. This will solve my probleme.
I would really appreciate your help
Have a look on these two threads where it's explained how to solve it.
In both cases it works with a manipulated new 'empty' bean from the origin type which the listmodel expects.
best
Stephan
I appreciate your help!
i tried to do something similar to thread1 , but still not working:
In my class ReparationController I added this:
public VehiculeModel getVehiculeModel() {
Vehicule vh=new Vehicule();
vh.setId_vehicule(-1);
vh.setImma_vehicule("Select ");
vehiculeModel.getAll().add(0, vh);
return vehiculeModel;
}
But can't figure out why it is not showing on th list??
please help
Asked: 2011-06-02 06:04:26 +0800
Seen: 718 times
Last updated: Jun 03 '11