ZK: zul get value from input form-data

2019-07-22 13:11发布

问题:

I need a help about ZK framework. This is my situation.

I have a html page:

<form id="frm1" action="http://localhost:8080/spuWebApp" METHOD="POST">
    <input type="hidden" id="codigoUnicoCliente" name="codigoUnicoCliente"  value="00000050055255">     
    <input type="button" onclick="myFunction()" value="Invar Spu POST URL">
</form>

Then, after submitting the form, my zk project recieves the data in bridge.zul.

<?init class="com.ibm.ibk.spu.view.BridgeChecker"?>

This class contains the following

public class BridgeChecker extends BaseWindow implements Initiator{


@Override
public void doInit(Page arg0, Map<String, Object> arg1) throws Exception {
    Bridge bridge = new Bridge();
    logger.debug("ANTIGUA MANERA");
    logger.debug(Executions.getCurrent().getParameterMap());
    logger.debug(Executions.getCurrent().getArg());
    logger.debug(Executions.getCurrent().getAttributes());

    bridge.setClienteCodigoUnicoFromURL(Executions.getCurrent().getParameter("codigoUnicoCliente"));

But I cant read the value.

I am racking my brain a lot. But I couldnt succeed in find out how to read the values. Someone who can help me to read the form-data. I'd appreciate it a lot.

Thanks in advanced.

回答1:

it work with Executions.getCurrent().getParameter("codigoUnicoCliente") but I do not know what myFunction() do, so I replace it with this code:

<form id="frm1" action="test.zul" METHOD="POST">
    <input type="hidden" id="codigoUnicoCliente" name="codigoUnicoCliente"  value="00000050055255">     
    <input type="submit" value="Invar Spu POST URL"> 
</form>

Then, I use following in test.zul

<window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('test.vm.TestViewModel')">

and then in TestViewModel

@Init
public void init(@ContextParam(ContextType.SESSION) Session session) {
   System.out.println(Executions.getCurrent().getParameter("codigoUnicoCliente"));
}

and work like charm :)



标签: html forms url zk