0

UiException on setting <h:li> elements class attribute with @load

asked 2015-07-31 09:38:45 +0800

LajB gravatar image LajB
1

Hey, I'm trying to set a native li elements class dynamically from the session with @load:

<h:li class="@load(sessionScope.selectedMenu)">

When I load the page I get this error:

org.zkoss.zk.ui.UiException: Cannot convert articleTable of type class java.lang.String to class java.lang.Class

ArticleTable is the value of the selectedMenu session attribute. It gives the same error when I try this:

<h:li class="@load('something')">

I also tried accessing session attribute with the ${sessionScope.selectedMenu} syntax, but it didn't give back any value, which is strange because I use the same syntax to access labels and that works fine.

Am I doing something wrong or this is just not possible?

Thanks!

delete flag offensive retag edit

Comments

The compiler expect for class a real class object. You give a string object. Thats why you have the fault.

chillworld ( 2015-08-01 18:42:05 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-07-31 18:22:10 +0800

Darksu gravatar image Darksu
1991 1 4

Hello ,

Please find below a working example:

Zul:

<zk>
<window xmlns="http://www.zkoss.org/2005/zul"
        apply="org.zkoss.bind.BindComposer"
        viewModel="@id('vm') @init('sample.SessionTest')">
            <textbox value="@bind(sessionScope.name)"/>
</window>
</zk>

Java:

package sample;

import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Sessions;
import org.zkoss.zk.ui.select.Selectors;

import java.io.Serializable;

public class SessionTest implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;


    @Init
    public void init() {
        Sessions.getCurrent().setAttribute("name", "test name");
    }


    @AfterCompose
    public void afterCompose(
            @ContextParam(ContextType.VIEW)
            Component view) {
        Selectors.wireComponents(view, this, false);

    }


}

Best Regards,

Darksu

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
1 follower

RSS

Stats

Asked: 2015-07-31 09:38:45 +0800

Seen: 11 times

Last updated: Jul 31 '15

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