0

listbox default value

asked 2011-06-02 06:04:26 +0800

soumaya gravatar image soumaya
99 1

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

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2011-06-02 11:15:13 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2011-06-02 11:21:52 +0800

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

link publish delete flag offensive edit

answered 2011-06-03 06:10:39 +0800

soumaya gravatar image soumaya
99 1

updated 2011-06-03 06:11:00 +0800

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

link publish delete flag offensive edit

answered 2011-06-03 07:47:40 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2011-06-03 07:48:52 +0800

Have a look on these two threads where it's explained how to solve it.

thread1
thread2

In both cases it works with a manipulated new 'empty' bean from the origin type which the listmodel expects.

best
Stephan

link publish delete flag offensive edit

answered 2011-06-03 10:15:26 +0800

soumaya gravatar image soumaya
99 1

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

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-06-02 06:04:26 +0800

Seen: 718 times

Last updated: Jun 03 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More