-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all.
Why, when I try to access the arg variable, I get the following error?
attempt to resolve method: get() on undefined variable or class name: arg
My zul file is as follows:
<window title="Apertura Pratica">
<zscript>
<![CDATA[
Long lProcessID = (Long) arg.get("ID");
]]>
</zscript>
</window>
Thanks!
I tried to replicate the problem in another simple app, but it seems it works in other scenarious.
One of the ZUL pages that do not works is the following:
<?page id="testZul" title=" New ZUL Title" cacheable="false" language="xul/html" zscriptLanguage="Java" contentType="text/html;charset=UTF-8"?> <?link rel="stylesheet" type="text/css" href="..."?> <zk xmlns="http://www.zkoss.org/2005/zul" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"> <window title="Apertura Pratica" id="wid" width="300px"> <zscript> import org.jbpm.JbpmConfiguration; import org.jbpm.JbpmContext; import org.jbpm.context.exe.ContextInstance; import org.jbpm.db.GraphSession; import org.jbpm.graph.def.Node; import org.jbpm.graph.exe.ProcessInstance; import org.jbpm.graph.exe.Token; import org.zkoss.zul.Label; import org.zkoss.zul.Row; import org.zkoss.zul.RowRenderer; import org.jbpm.taskmgmt.exe.TaskInstance; //Long lTaskID = Executions.getCurrent().getArg().get("ID"); Long lTaskID = arg.get("ID"); Long lProcessID = null; JbpmContext jbpmContext = null; List vFiles = new ArrayList(); String sSocieta = ""; try { jbpmContext = JbpmConfiguration.getInstance().createJbpmContext(); //Prelevo il process id TaskInstance ti = jbpmContext.getTaskInstance(lTaskID.longValue()); ProcessInstance pi = ti.getProcessInstance(); lProcessID = new Long(pi.getId()); ////////////////////////////// List v = (List) pi.getContextInstance().getVariable("AP_FILES"); sSocieta = (String) pi.getContextInstance().getVariable("SOCIETA"); if (v != null) vFiles = v; if (sSocieta == null) sSocieta = ""; //alert(pi); } finally { if (jbpmContext != null) jbpmContext.close(); } </zscript> <vbox> <grid> <rows> <row> Nome Societa' : <textbox id="societa" text="${sSocieta}"/> </row> </rows> </grid> Lista Documenti allegati: <grid id="fileList"> <columns> <column label="Nome File"/> </columns> </grid> <zscript> Grid g = Path.getComponent("/wid/fileList"); g.setModel(new SimpleListModel(vFiles)); void onSave() { Window w = (Window) Path.getComponent("/wid"); Textbox txtSocieta = (Textbox) Path.getComponent("/wid/societa"); JbpmContext jbpmContext = null; try { jbpmContext = JbpmConfiguration.getInstance().createJbpmContext(); //GraphSession graphSession = jbpmContext.getGraphSession(); ProcessInstance pi = jbpmContext.getProcessInstance(lProcessID.longValue()); //List v = (List) pi.getContextInstance().getVariable("AP_FILES"); //if (v != null) // vFiles = v; pi.getContextInstance().setVariable("AP_FILES", vFiles); pi.getContextInstance().setVariable("SOCIETA", txtSocieta.getText()); jbpmContext.save(pi); } finally { if (jbpmContext != null) jbpmContext.close(); } w.detach(); } void onValidate() { Window w = (Window) Path.getComponent("/wid"); Textbox txtSocieta = (Textbox) Path.getComponent("/wid/societa"); JbpmContext jbpmContext = null; try { jbpmContext = JbpmConfiguration.getInstance().createJbpmContext(); //GraphSession graphSession = jbpmContext.getGraphSession(); ProcessInstance pi = jbpmContext.getProcessInstance(lProcessID.longValue()); //List v = (List) pi.getContextInstance().getVariable("AP_FILES"); //if (v != null) // vFiles = v; pi.getContextInstance().setVariable("AP_FILES", vFiles); pi.getContextInstance().setVariable("SOCIETA", txtSocieta.getText()); TaskInstance ti = jbpmContext.getTaskInstance(lTaskID.longValue()); ti.end("validazione"); jbpmContext.save(pi); } finally { if (jbpmContext != null) jbpmContext.close(); } w.detach(); } </zscript> <button label="Allega Nuovo File"> <attribute name="onClick"> { Object media = Fileupload.get(); if (media != null) { String s = media.getName(); vFiles.add(s); Grid g = Path.getComponent("/wid/fileList"); g.setModel(new SimpleListModel(vFiles)); } } </attribute> </button> <hbox> <button label="Salva Modifiche" onClick="onSave()"/> <button label="Invia in approvazione" onClick="onValidate()"/> </hbox> </vbox> </window> </zk>
My application works like this:
I have a workflow, managed through JBPM.
I want all the pages to be embedded inside the workflow, so that I can change the workflow, without the need to change the WEB application.
I solved it this way: inside the workflow package (the .par archive), I put all the pages needed to handle the workflow step.
Than, as on enter event of each step, I create a variable that holds the content of the zul page.
In my web application, I simply ask the flow item to give me the source of the zul page needed to handle itself. Then I create the page with Executions.createComponentDirectly.
The code that creates the page, is:
private Window createPage(Long lProcessID) { JbpmContext jbpmContext = null; try { jbpmContext = JbpmConfiguration.getInstance().createJbpmContext(); //GraphSession graphSession = jbpmContext.getGraphSession(); TaskInstance ti = jbpmContext.getTaskInstance(lProcessID.longValue()); ProcessInstance pi = ti.getProcessInstance(); //ProcessInstance pi = jbpmContext.getProcessInstance(); //ProcessInstance pi = (ProcessInstance) graphSession.findProcessInstances().get(0); String sPage = (String) pi.getContextInstance().getVariable("PAGE"); Map args = new HashMap(); args.put("ID", lProcessID); return (Window) Executions.createComponentsDirectly(sPage, "zul", null, args); } finally { if (jbpmContext != null) jbpmContext.close(); } }
Thank you.
I though so.
As I told you, with simpler examples, it works.
If I should ever be able to produce an example, I'll post it again here.
However, in the meanwhile, I'll keep on using the Path object to access the components..
Thanks for your support.
It looks like a wrong bsh.jar problem, do you use the bsh.jar form official download of zk package or a older one.
Asked: 2008-11-05 08:28:01 +0800
Seen: 522 times
Last updated: Nov 10 '08