📄 showwork.java
字号:
/** * */package pagecode.article;import java.rmi.RemoteException;import javax.ejb.EJBException;import javax.faces.component.html.HtmlForm;import javax.faces.context.FacesContext;import pagecode.PageCodeBase;import com.ibm.faces.component.html.HtmlScriptCollector;import com.ibm.gbsc.cte.sample.ApiHelper;import com.ibm.gbsc.cte.sample.Constants;import com.ibm.gbsc.cte.sample.HumanTaskInstruction;import com.ibm.gbsc.cte.sample.HumanTaskXMLConfigLoader;import com.ibm.task.api.HumanTaskManager;import com.ibm.task.api.Task;import com.ibm.task.api.TaskException;import commonj.sdo.DataObject;/** * @author Kyle * */public class ShowWork extends PageCodeBase { protected HtmlScriptCollector scriptCollector1; protected HumanTaskInstruction hti = null; protected HtmlForm form1; protected String tkiid = ""; protected String userChoice = "2"; protected String userInput = ""; public void onPageLoad(FacesContext context) { // get the task id of user request String strTkiid = (String) this.getRequestParam().get("tkiid"); System.out.println("request tkiid is:" + tkiid); if (strTkiid != null && !"".endsWith(strTkiid)) { setTkiid(strTkiid); // get human task manager HumanTaskManager htm = null; try { htm = ApiHelper.initializeHTM(); // get custom properties String htmType = htm.getCustomProperty(tkiid, Constants.CUSTOM_PROP_HTM_TYPE); // retrieve this human task type from xml file, and your view // logic is here // e.g. show instructions or show yes/no button etc. System.out.println("htmType is :" + htmType); //parsing xml to get the properties hti = HumanTaskXMLConfigLoader.getTaskInstruction(htmType); // } catch (TaskException e) { e.printStackTrace(); } catch (RemoteException e) { e.printStackTrace(); } catch (EJBException e) { e.printStackTrace(); } finally { htm = null; } } } public String processUserClick(){ HumanTaskManager htm = null; try { System.out.println("tkiid is : " + tkiid+ "!!!"); htm = ApiHelper.initializeHTM(); Task task = htm.getTask(tkiid); //ready state if(task.getState()== Task.STATE_READY){ //claim task htm.claim(tkiid); //get wrap object com.ibm.task.api.ClientObjectWrapper wrapper = htm.createOutputMessage(tkiid); if (wrapper.getObject() != null && wrapper.getObject() instanceof DataObject) { // get input data object DataObject input = (DataObject) wrapper.getObject(); // transform input.set("userChoice", new Integer(userChoice)); //input.set("userInput", userInput); } // using task api to complete task htm.complete(tkiid, wrapper); //record approval history to file, you can //replace this logic with database.// Constants.writeToFile(tkiid, userInput); } } catch (TaskException e) { e.printStackTrace(); } catch (RemoteException e) { e.printStackTrace(); } catch (EJBException e) { e.printStackTrace(); } finally{ htm = null; } return "home"; } protected HtmlScriptCollector getScriptCollector1() { if (scriptCollector1 == null) { scriptCollector1 = (HtmlScriptCollector) findComponentInRoot("scriptCollector1"); } return scriptCollector1; } /** * @return the hti */ public HumanTaskInstruction getHti() { return hti; } /** * @param hti the hti to set */ public void setHti(HumanTaskInstruction hti) { this.hti = hti; } protected HtmlForm getForm1() { if (form1 == null) { form1 = (HtmlForm) findComponentInRoot("form1"); } return form1; } /** * @return the userChoice */ public String getUserChoice() { return userChoice; } /** * @param userChoice the userChoice to set */ public void setUserChoice(String userChoice) { this.userChoice = userChoice; } /** * @return the tkiid */ public String getTkiid() { return tkiid; } /** * @param tkiid the tkiid to set */ public void setTkiid(String tkiid) { this.tkiid = tkiid; } /** * @return the userInput */ public String getUserInput() { return userInput; } /** * @param userInput the userInput to set */ public void setUserInput(String userInput) { this.userInput = userInput; }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -