2

Hi I'm trying to pass data from my customGraphService to my ZUL Page through a customGraphController. But it won't display it.

customGraphService

public class customGraphService {

    public String test(){
        return "this is a test";
    }


}

customGraphController

import com.hybris.cockpitng.core.model.WidgetModel;

import org.training.services.customGraphService;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.annotation.WireVariable;

import com.hybris.cockpitng.util.DefaultWidgetController;


public class customGraphController extends DefaultWidgetController
{

    @WireVariable
    private transient customGraphService customGraphService;

    @Override
    public void preInitialize(Component comp) {
        super.preInitialize(comp);
        // get the model
        WidgetModel model = getModel();
        model.put("test", customGraphService.test());

    }
}

ZUL PAGE CODE

        <h:body>
            <h:div>
                <h:canvas id="myChart"></h:canvas>
            </h:div>
            <h:div>
                <h:div value="${widgetModel.test}"></h:div>
            </h:div>

        </h:body>
  • 1
    After a long search with tears and blood I found the issue. Since customGraphController is a serializable class if needs an serialVersionID. I used save Actions to generate this for all serializable classes. now it works... – codesenpai_ Nov 26 '21 at 15:59
  • life saver! I will try that and update if it works for me. Perhaps you could also answer and accept your own question with this comment. – Eric Yew Nov 27 '21 at 04:32
  • Glad I found it :D , yes I will put on the answer soon – codesenpai_ Nov 28 '21 at 10:09

1 Answers1

1

Need to add a serialVersionUID since the super class is serializable.


public class customGraphController extends DefaultWidgetController {

    private static final long serialVersionUID = herecomesyouruid;


...