ZK: zul get value from input form-data

匿名 (未验证) 提交于 2019-12-03 01:06:02

问题:

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 :)



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!