1

bind a component to null database object

asked 2012-06-06 12:12:50 +0800

livermr gravatar image livermr
16 1

updated 2014-05-06 11:59:01 +0800

sitansu gravatar image sitansu
2254 13
http://java91.blogspot.in...

Please, help me about this case:

<textbox id="family_name" value="@bind(fx.subjVersion.familyNameLat.original)"></textbox>

I work with Hibernate. In the database subjVersion have foreign key to familyNameLat (table), which have column "original (String)".

So the problem is:

when in subjVersioin table row, column familyNameLat is null and .zul form is generated, the component "<textbox id="family_name" ......"="" was="" associated="" with="" a="" null="" object.="" <="" p="">

And when I try to submit form throws this exception: "Target Unreachable, 'firstNameLat' returned null".

How to resolve this issue?

I work with MVVM.

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2014-05-11 17:15:46 +0800

nmpallas gravatar image nmpallas
115 4
http://nmpallas.wordpress...

You are using form binding. Therefor take into account that there is also an intermediate object generated(POJO like) right? Thus this object is automatically handled by zk framework and you should handle in a specific manner described in the tutorial for form binding. On top of that the @bind() you must have initialized an object to map the @bind values or you are binding to the null object. The solution would be on the @Init to check if the entity you want to represent in the form is null and if such create a new instance of it. A bit different story if you want to do and update in that case on the select of the entity to update you have to map the entity say customer = findCustomer(id) and bind the information to the form using the data binding mechanism.

link publish delete flag offensive edit
0

answered 2014-05-02 09:33:58 +0800

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

updated 2014-05-02 10:25:46 +0800

PUSH PUSH PUSH!

Please give us an answer with codes for this really 'real world' sample. This should be handled in the documentation.

thanks Stephan

<div form="@id('fx') @init(vm.myForm) @load(vm.selectedRecord) @save(vm.selectedRecord, before='onSave')">

    . . .
<textbox value="@bind(fx.customer.name1) @validator(vm.oxValidatorNotNull)" readonly="true" hflex="1" />

Target unreachable, 'customer' returned null

--> The validator is never called

selectedRecord=project

project.customer.name1

link publish delete flag offensive edit
0

answered 2014-05-06 09:32:53 +0800

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

Ok. After thinking about the error i should say that this is not a zk or binder issue.

By using a deeper path of the properties like 'project.customer.name' the user/developer must ensure that the bean that holds the property 'name' is not null.

I do it now by setting a new empty 'customer' object before the binder have acces to it.

thanks Stephan

link publish delete flag offensive edit
Your answer
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: 2012-06-06 12:12:50 +0800

Seen: 256 times

Last updated: May 11 '14

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