0

Is there anyway to forward variable into MVC zul page? Take example in list/grid with button and foreach.

asked 2023-11-10 15:49:06 +0800

BenLimanto gravatar image BenLimanto
1 1

updated 2023-11-10 15:51:04 +0800

As title state, is it possible to make it possible?

example on the button on list cell, I need to take id from the models, but now I use autag for it

<template name="model">
    <listitem>
        <listcell label="${each.id}" />
        <listcell label="${each.name}" />
        <listcell label="${each.pricing}" />
        <listcell>
            <button label="Edit Query Param" autag="${each.id}" sclass="btnEdit" />
            <button label="Edit Path" autag="${each.id}" sclass="btnEditParam" />
        </listcell>
    </listitem>
</template>

I'm thinking like on MVVM, like Parameters or @BindingParam (org.zkoss.bind.annotation.BindingParam), or it's not possible with the MVC approach in zul?

Like Example if we use MVVM we can use zul

   <menuitem label="Index" onClick="@command('GoToUrl', url='/')" />

and get it using @BindParam for url variable

@Command
public void GoToUrl(@BindingParam("url") String url)
{
    Executions.sendRedirect(url);
}

For Now I'm using autag and it ends up with horrible code like this

@Listen("onClick = listcell > button.btnEdit; onOK = window")
public void goToEdit(MouseEvent event)
{
    var p = (Button) event.getTarget();
    String id = p.getAutag();
    Executions.sendRedirect("/product/edit?id="+id);
}

@Listen("onClick = listcell > button.btnEditParam; onOK = window")
public void goToEditParam(MouseEvent event)
{
    var p = event.getTarget();
    String id = p.getAutag();
    Executions.sendRedirect("/product/edit/"+id);
}

I'm thinking like

@Listen("onClick = listcell > button.btnEditParam; onOK = window")
public void goToEditParam(MouseEvent event, @BindingParam Integer id)
{
    var p = event.getTarget();
    String id = p.getAutag();
    Executions.sendRedirect("/product/edit/"+id);
}

I still can't think how to map it from the zul or GUI part.

delete flag offensive retag edit
Be the first one to answer this question!
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: 2023-11-10 15:49:06 +0800

Seen: 2 times

Last updated: Nov 10 '23

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