0

MVVM Property Not found error - URGENT ISSUE

asked 2012-06-26 11:55:31 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Hi

Can someone tell me what is the wrong in the following code

demo1.zul

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
	<window id="AppRoles" title="Application Roles" border="normal"
		apply="org.zkoss.bind.BindComposer"
		viewModel="@id('role') @init('test.demo1VM')">
		<checkbox label="Show only active"
			checked="@bind(role.IS_ACTIVE)" />

		<button id="submit" label="Submit" onClick="@command('save')" />
	</window>
</zk>


demo1VM.java

package test;

public class demo1VM {

	private Boolean IS_ACTIVE = true;

	public Boolean IS_ACTIVE() {
		return IS_ACTIVE;
	}

	public void setIS_ACTIVE(Boolean iS_ACTIVE) {
		IS_ACTIVE = iS_ACTIVE;
	}
	

}


When i run, the following error occurred


ype Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.zkoss.zel.PropertyNotFoundException: Property 'IS_ACTIVE' not readable on type java.lang.Boolean
org.zkoss.zel.BeanELResolver$BeanProperty.read(BeanELResolver.java:348)
org.zkoss.zel.BeanELResolver$BeanProperty.access$000(BeanELResolver.java:274)
org.zkoss.zel.BeanELResolver.getValue(BeanELResolver.java:85)
org.zkoss.zel.CompositeELResolver.getValue(CompositeELResolver.java:67)
org.zkoss.zel.CompositeELResolver.getValue(CompositeELResolver.java:67)
org.zkoss.xel.zel.XelELResolver.getValue(XelELResolver.java:71)
org.zkoss.bind.xel.zel.BindELResolver.getValue(BindELResolver.java:64)
org.zkoss.zel.impl.parser.AstValue.getValue(AstValue.java:179)
org.zkoss.zel.impl.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
org.zkoss.xel.zel.ELXelExpression.evaluate(ELXelExpression.java:40)
org.zkoss.bind.impl.BindEvaluatorXImpl.getValue(BindEvaluatorXImpl.java:44)
org.zkoss.bind.impl.LoadPropertyBindingImpl.load(LoadPropertyBindingImpl.java:55)
org.zkoss.bind.impl.PropertyBindingHandler.doLoadBinding(PropertyBindingHandler.java:172)
org.zkoss.bind.impl.PropertyBindingHandler.doLoad(PropertyBindingHandler.java:373)
org.zkoss.bind.impl.BinderImpl.loadComponentProperties(BinderImpl.java:1758)
org.zkoss.bind.impl.BinderImpl.loadComponent(BinderImpl.java:1740)
org.zkoss.bind.impl.BinderImpl.loadComponent(BinderImpl.java:1742)
org.zkoss.bind.BindComposer.doAfterCompose(BindComposer.java:128)
org.zkoss.zk.ui.impl.UiEngineImpl.doAfterCompose(UiEngineImpl.java:526)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:821)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:767)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:676)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:738)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:698)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:640)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:391)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:313)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:214)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:134)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.

delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2012-06-26 12:10:10 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

Hey Senthil,

You're not using the java naming pattern. And then the EL resolver is attempting to access the private variable IS_ACTIVE, but as a private variable, it cannot be accessed from outside.

You should refactor your code using the java standarts, try this way:

demo.zul

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
	<window id="AppRoles" title="Application Roles" border="normal"
		apply="org.zkoss.bind.BindComposer"
		viewModel="@id('role') @init('test.demo1VM')">
		<checkbox label="Show only active"
			checked="@bind(role.active)" />

		<button id="submit" label="Submit" onClick="@command('save')" />
	</window>
</zk>

demo1VM.java

package test;

public class demo1VM {

	private Boolean active = true;

        // I do believe that EL can resolve this, but if don't work, you'll have to change the method name to getActive()
	public Boolean isActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}
	

}

HTH,
Madruga

link publish delete flag offensive edit

answered 2012-06-26 14:37:57 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Hi

Thanks. But still gives the same problem

link publish delete flag offensive edit

answered 2012-06-26 15:19:35 +0800

rickcr gravatar image rickcr
704 7

how did you define you checked bound property? You had:

checked="@bind(role.IS_ACTIVE)

with the new code it would be

checked="@bind(role.active)

Note like Madruga mentioned, you might need a getter for a wrapper Boolean (getActive()) instead of isActive()) isActive should work fine for the primitive boolean. I usually use primitives for my booleans so haven't tested with Boolean.

link publish delete flag offensive edit

answered 2012-06-26 17:32:57 +0800

rickcr gravatar image rickcr
704 7

updated 2012-06-26 17:33:32 +0800

Note, I just had to implement this kind of thing myself just now in my VM and it's working just fine...

//VM

private boolean showShared;

public boolean isShowShared() { 
	return showShared;
}

@NotifyChange("productGroups")
public void setShowShared(boolean showShared) { 
	this.showShared = showShared;
}

//zul

<hbox>
	<checkbox label="Show Shared" checked="@bind(vm.showShared)" ></checkbox>
</hbox>
<listbox model="@bind(vm.productGroups)" selectedItem="@bind(vm.selectedProductGroup)">

link publish delete flag offensive edit

answered 2012-07-30 10:07:43 +0800

voidlee gravatar image voidlee
3

I have the same problem too!

I use a boolean property name of "CommCheck1_1"
get error -> PropertyNotFoundException: Property 'CommCheck1_1'

when I change the property name to "commCheck1_1"
working fine , no problem now

Is it a bug? or some framework issue (spring)?

link publish delete flag offensive edit

answered 2012-07-30 10:27:52 +0800

riczun gravatar image riczun
36 2
www.riczun.nl

Seems no bug to me, because properties may not start with a capital in Java. ZK will not find the right getter/setter for the property.

link publish delete flag offensive edit

answered 2014-03-14 15:34:59 +0800

stanislav gravatar image stanislav
0

The problem still exists. And it's repeatable, if you are using "Boolean" instead of "boolean". And it's the issue, if you are using generated JAXB classes with minoccurs="0" on boolean properties.

link publish delete flag offensive edit

answered 2014-03-14 15:35:24 +0800

stanislav gravatar image stanislav
0

The problem still exists. And it's repeatable, if you are using "Boolean" instead of "boolean". And it's the issue, if you are using generated JAXB classes with minoccurs="0" on boolean properties.

link publish delete flag offensive edit

answered 2014-03-14 15:55:00 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

The sample works well for me: MVVM test

Just copied your code and change 'public Boolean ISACTIVE()' to 'public Boolean getISACTIVE()'

To solve this issue you can use XJC plugin to generate getter for Boolean field, please refer to getter for boolean properties with JAXB

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: 2012-06-26 11:55:31 +0800

Seen: 569 times

Last updated: Mar 14 '14

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