0

org.zkoss.zk.ui.UiException: can't find Page to resolve a view model class [closed]

asked 2015-01-07 19:34:00 +0800

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

org.zkoss.zk.ui.UiException: can't find Page to resolve a view model class :'com.product.webapp.billing.ClaimMainVM' at [file:/F:/MyDocuments/Java/ZK7PMS/HealthSystem/Healthcare/src/main/webapp/zk/billing/claimmain.zul, line:4, nearby column: 39]

I am getting the error sometime. Not able to trace it. But sometime it works well

delete flag offensive retag edit

The question has been closed for the following reason "not a real question" by cor3000
close date 2015-01-08 06:37:00

9 Answers

Sort by ยป oldest newest most voted
0

answered 2015-01-08 03:48:07 +0800

cor3000 gravatar image cor3000
4406 2 7
ZK Team

this error happens in org.zkoss.bind.BindComposer.initViewModel(BindEvaluatorX, Component) in case the component is not attached to a page when it is initialized.

with the current details I cannot tell what leads to this situation in your case. Can you post the relevant code of your zul file, and any related code, that maybe creates/adds/removes this component dynamically? Then I can have a closer look.

Robert

link publish delete flag offensive edit
0

answered 2015-01-08 05:01:33 +0800

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

Thank you robert. I will take one more look in detail and let you know. Because it works well in other places with the same code.

link publish delete flag offensive edit

Comments

the error doesn't have to originate in "claimmain.zul" directly it could be related to how/when "claimmain.zul" is included, or created

cor3000 ( 2015-01-08 05:32:03 +0800 )edit
0

answered 2015-01-08 05:50:07 +0800

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

Yes it is related to container component issue when trying to load the zul file. Sorry to include another issue here. I am also getting the following which could not able to trace it image description

I have a global error handler and on clicking the close button i am getting the client error.

link publish delete flag offensive edit

Comments

PLEASE keep questions separate...

cor3000 ( 2015-01-08 06:16:11 +0800 )edit
0

answered 2015-01-08 05:50:53 +0800

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

updated 2015-01-08 05:57:41 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

Here is the error zul file

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
    <window title="Application Error Handler" mode="modal" border="normal"
        maximizable="false" closable="true" position="center,parent"
        action="hide: slideUp" sclass="mymodal" id="errordialog"
        onCancel="@command('closeThis')" apply="org.zkoss.bind.BindComposer"
        viewModel="@id('vm') @init('com.product.webapp.main.ErrorDialogVM')">
        <separator />
        <hlayout sclass="z-valign-middle">
            <fimageerror onClick="@command('showErrorDetail')" />
            <flabel value="We're Sorry! " sclass="flblerror" />
            <space></space>
        </hlayout>
        <separator />
        <label pre="true" value="@bind(vm.sorryMessage)" />
        <separator />
        <separator />
        <flabel value="We apologize for the inconvenience." />
        <div width="100%" sclass="sectionSeperator"
            style="margin-left: 0px;">
        </div>
        <div align="center">
            <fbutton label="Close" id="Close"
                onClick="@command('closeThis')" />
        </div>
    </window>
</zk>
link publish delete flag offensive edit
0

answered 2015-01-08 05:51:15 +0800

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

updated 2015-01-08 05:58:53 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

Here is the VM

package com.product.webapp.main;

import java.util.HashMap;

import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.bind.annotation.ExecutionArgParam;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Sessions;
import org.zkoss.zk.ui.select.Selectors;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Window;

public class ErrorDialogVM {

    @Wire("#errordialog")
    private Window win;

    private Integer errCode;
    private String errMessage;
    private String sorryMessage;
    private Exception exception;
    private String moreErrorInfo;

    public String getSorryMessage() {
        return sorryMessage;
    }

    public void setSorryMessage(String sorryMessage) {
        this.sorryMessage = sorryMessage;
    }

    public String getMoreErrorInfo() {
        return moreErrorInfo;
    }

    public void setMoreErrorInfo(String moreErrorInfo) {
        this.moreErrorInfo = moreErrorInfo;
    }

    @AfterCompose
    public void initSetup(@ContextParam(ContextType.VIEW) Component view,
            @ExecutionArgParam("map") HashMap<String, Object> map) {
        Selectors.wireComponents(view, this, false);
        this.errCode = 0;
        this.errMessage = "";
        this.exception = (Exception) map.get("Exception");
        this.moreErrorInfo = (String) map.get("moreErrorInfo");
        this.sorryMessage = "An unexpected error occured.Our Engineers have been notified of this \nproblem and expect to resolve it shortly.";
    }

    @Command
    public void closeThis() {
        win.detach();
    }

    @Command
    public void showErrorDetail() {
        final HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("errCode", this.errCode);
        map.put("errMessage", this.errMessage);
        map.put("exception", this.exception);
        map.put("errFrom", "Application Error Handler");
        map.put("moreErrorInfo", moreErrorInfo);
        Sessions.getCurrent().setAttribute("errordetail", map);
        Executions.getCurrent().sendRedirect("/errordetail.zul", "_blank");
        win.detach();
    }

}
link publish delete flag offensive edit

Comments

Senti, wouldn't it be better to use @Init in stead of the MVC way @AfterCompose (the wire you could also remove with @ContextParam(ContextType.VIEW) Component view in the command. If you remove the zk tag I'm sure the component is instance of window.

chillworld ( 2015-01-08 06:04:30 +0800 )edit

The zk is a null component to be XML applient, but if you remove it, your zul is still xml applient cause window is the root tag.

chillworld ( 2015-01-08 06:05:17 +0800 )edit

Senthil: I can hardly follow what you are talking about... first you started with "ClaimMainVM" and now switch to ErrorDialogVM... are we still talking about the initial error, and is this a reproducible case?

cor3000 ( 2015-01-08 06:20:27 +0800 )edit
0

answered 2015-01-08 06:16:20 +0800

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

No Luck after your suggestion. In the console, i can see the following error 11:45:20.586 [http-bio-8080-exec-10] ERROR org.zkoss.zk.ui.impl.DesktopImpl - [Desktop z_cic:/zk/main/main.zul] client error: Failed to process rm Cannot read property '$n' of null (TypeError)

link publish delete flag offensive edit
0

answered 2015-01-08 06:16:42 +0800

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

Again, it occurs sometime and sometime it works well :)

link publish delete flag offensive edit
0

answered 2015-01-08 06:23:40 +0800

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

aha, i found the problem. If i remove the following code in zul , it works fine

action="hide: slideUp"

but i have the same thing in all my project with same ZK Version, there it works well.

link publish delete flag offensive edit
0

answered 2015-01-08 06:36:36 +0800

cor3000 gravatar image cor3000
4406 2 7
ZK Team

I'll close this thread, please only ask one question per thread, otherwise this post is difficult to follow, and does not answer the topic.

link publish delete flag offensive edit

Question tools

Follow
2 followers

RSS

Stats

Asked: 2015-01-07 19:34:00 +0800

Seen: 81 times

Last updated: Jan 08 '15

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