use of org.compiere.model.MProcess in project adempiere by adempiere.
the class SvrProcess method validateParameter.
// process
/**
* Validate Parameters
*/
private void validateParameter() {
MProcess process = MProcess.get(getCtx(), processInfo.getAD_Process_ID());
// No have parameter
if (process == null)
return;
//
MProcessPara[] parameters = process.getParameters();
StringBuffer errorMsg = new StringBuffer();
// Loop over parameter, find a mandatory parameter
for (MProcessPara parameter : parameters) {
if (parameter.isMandatory() && parameter.isActive()) {
ProcessInfoParameter infoParameter = getInfoParameter(parameter.getColumnName());
if (infoParameter == null || infoParameter.getParameter() == null || (DisplayType.isID(parameter.getAD_Reference_ID()) && ((infoParameter.getParameter() instanceof String && infoParameter.getParameterAsString() == null) || (infoParameter.getParameter() instanceof Number && infoParameter.getParameterAsInt() < 0))) || (DisplayType.isText(parameter.getAD_Reference_ID()) && (infoParameter.getParameterAsString() == null || infoParameter.getParameterAsString().length() == 0))) {
if (errorMsg.length() > 0) {
errorMsg.append(", ");
}
//
errorMsg.append("@").append(parameter.getColumnName()).append("@");
}
}
}
// throw exception
if (errorMsg.length() > 0) {
throw new AdempiereException(MESSAGE_FillMandatory + errorMsg.toString());
}
}
use of org.compiere.model.MProcess in project adempiere by adempiere.
the class MWFActivity method performWork.
// run
/**
* Perform Work.
* Set Text Msg.
* @param trx transaction
* @return true if completed, false otherwise
* @throws Exception if error
*/
private boolean performWork(Trx trx) throws Exception {
log.info(m_node + " [" + trx.getTrxName() + "]");
m_docStatus = null;
if (// overwrite priority if defined
m_node.getPriority() != 0)
setPriority(m_node.getPriority());
String action = m_node.getAction();
/****** Sleep (Start/End) ******/
if (MWFNode.ACTION_WaitSleep.equals(action)) {
log.fine("Sleep:WaitTime=" + m_node.getWaitTime());
if (m_node.getWaitingTime() == 0)
// done
return true;
Calendar cal = Calendar.getInstance();
cal.add(m_node.getDurationCalendarField(), m_node.getWaitTime());
setEndWaitTime(new Timestamp(cal.getTimeInMillis()));
// not done
return false;
} else /****** Document Action ******/
if (MWFNode.ACTION_DocumentAction.equals(action)) {
log.fine("DocumentAction=" + m_node.getDocAction());
getPO(trx);
if (m_po == null)
throw new Exception("Persistent Object not found - AD_Table_ID=" + getAD_Table_ID() + ", Record_ID=" + getRecord_ID());
boolean success = false;
String processMsg = null;
DocAction doc = null;
if (m_po instanceof DocAction) {
doc = (DocAction) m_po;
//
try {
// ** Do the work
success = doc.processIt(m_node.getDocAction());
setTextMsg(doc.getSummary());
processMsg = doc.getProcessMsg();
// the rest of methods return boolean, so doc status must not be taken into account when not successful
if (DocAction.ACTION_Prepare.equals(m_node.getDocAction()) || DocAction.ACTION_Complete.equals(m_node.getDocAction()) || success)
m_docStatus = doc.getDocStatus();
} catch (Exception e) {
if (m_process != null)
m_process.setProcessMsg(e.getLocalizedMessage());
throw e;
}
if (m_process != null)
m_process.setProcessMsg(processMsg);
} else
throw new IllegalStateException("Persistent Object not DocAction - " + m_po.getClass().getName() + " - AD_Table_ID=" + getAD_Table_ID() + ", Record_ID=" + getRecord_ID());
//
if (!m_po.save()) {
success = false;
processMsg = "SaveError";
}
if (!success) {
if (processMsg == null || processMsg.length() == 0) {
processMsg = "PerformWork Error - " + m_node.toStringX();
if (// problem: status will be rolled back
doc != null)
processMsg += " - DocStatus=" + doc.getDocStatus();
}
throw new Exception(processMsg);
}
return success;
} else /****** Report ******/
if (MWFNode.ACTION_AppsReport.equals(action)) {
log.fine("Report:AD_Process_ID=" + m_node.getAD_Process_ID());
// Process
MProcess process = MProcess.get(getCtx(), m_node.getAD_Process_ID());
process.set_TrxName(trx != null ? trx.getTrxName() : null);
if (!process.isReport() || process.getAD_ReportView_ID() == 0)
throw new IllegalStateException("Not a Report AD_Process_ID=" + m_node.getAD_Process_ID());
//
ProcessInfo pi = new ProcessInfo(m_node.getName(true), m_node.getAD_Process_ID(), getAD_Table_ID(), getRecord_ID());
pi.setAD_User_ID(getAD_User_ID());
pi.setAD_Client_ID(getAD_Client_ID());
MPInstance pInstance = new MPInstance(process, getRecord_ID());
pInstance.set_TrxName(trx != null ? trx.getTrxName() : null);
fillParameter(pInstance, trx);
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
// Report
ReportEngine re = ReportEngine.get(getCtx(), pi);
if (re == null)
throw new IllegalStateException("Cannot create Report AD_Process_ID=" + m_node.getAD_Process_ID());
File report = re.getPDF();
// Notice
// HARDCODED WorkflowResult
int AD_Message_ID = 753;
MNote note = new MNote(getCtx(), AD_Message_ID, getAD_User_ID(), trx.getTrxName());
note.setTextMsg(m_node.getName(true));
note.setDescription(m_node.getDescription(true));
note.setRecord(getAD_Table_ID(), getRecord_ID());
note.saveEx();
// Attachment
MAttachment attachment = new MAttachment(getCtx(), MNote.Table_ID, note.getAD_Note_ID(), get_TrxName());
attachment.addEntry(report);
attachment.setTextMsg(m_node.getName(true));
attachment.saveEx();
return true;
} else /****** Process ******/
if (MWFNode.ACTION_AppsProcess.equals(action)) {
log.fine("Process:AD_Process_ID=" + m_node.getAD_Process_ID());
// Process
MProcess process = MProcess.get(getCtx(), m_node.getAD_Process_ID());
MPInstance pInstance = new MPInstance(process, getRecord_ID());
fillParameter(pInstance, trx);
//
ProcessInfo pi = new ProcessInfo(m_node.getName(true), m_node.getAD_Process_ID(), getAD_Table_ID(), getRecord_ID());
pi.setAD_User_ID(getAD_User_ID());
pi.setAD_Client_ID(getAD_Client_ID());
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
return process.processItWithoutTrxClose(pi, trx);
} else /****** EMail ******/
if (MWFNode.ACTION_EMail.equals(action)) {
log.fine("EMail:EMailRecipient=" + m_node.getEMailRecipient());
getPO(trx);
if (m_po == null)
throw new Exception("Persistent Object not found - AD_Table_ID=" + getAD_Table_ID() + ", Record_ID=" + getRecord_ID());
if (m_po instanceof DocAction) {
m_emails = new ArrayList<String>();
sendEMail();
setTextMsg(m_emails.toString());
} else {
MClient client = MClient.get(getCtx(), getAD_Client_ID());
MMailText mailtext = new MMailText(getCtx(), getNode().getR_MailText_ID(), null);
String subject = getNode().getDescription() + ": " + mailtext.getMailHeader();
String message = mailtext.getMailText(true) + "\n-----\n" + getNodeHelp();
String to = getNode().getEMail();
client.sendEMail(to, subject, message, null);
}
// done
return true;
} else /****** Set Variable ******/
if (MWFNode.ACTION_SetVariable.equals(action)) {
String value = m_node.getAttributeValue();
log.fine("SetVariable:AD_Column_ID=" + m_node.getAD_Column_ID() + " to " + value);
MColumn column = m_node.getColumn();
int dt = column.getAD_Reference_ID();
return setVariable(value, dt, null, trx);
} else /****** TODO Start WF Instance ******/
if (MWFNode.ACTION_SubWorkflow.equals(action)) {
log.warning("Workflow:AD_Workflow_ID=" + m_node.getAD_Workflow_ID());
log.warning("Start WF Instance is not implemented yet");
} else /****** User Choice ******/
if (MWFNode.ACTION_UserChoice.equals(action)) {
log.fine("UserChoice:AD_Column_ID=" + m_node.getAD_Column_ID());
// Approval
if (m_node.isUserApproval() && getPO(trx) instanceof DocAction) {
DocAction doc = (DocAction) m_po;
boolean autoApproval = false;
// Approval Hierarchy
if (isInvoker()) {
// Set Approver
int startAD_User_ID = Env.getAD_User_ID(getCtx());
if (startAD_User_ID == 0)
startAD_User_ID = doc.getDoc_User_ID();
int nextAD_User_ID = getApprovalUser(startAD_User_ID, doc.getC_Currency_ID(), doc.getApprovalAmt(), doc.getAD_Org_ID(), // own doc
startAD_User_ID == doc.getDoc_User_ID());
// same user = approved
autoApproval = startAD_User_ID == nextAD_User_ID;
if (!autoApproval)
setAD_User_ID(nextAD_User_ID);
} else // fixed Approver
{
MWFResponsible resp = getResponsible();
// [ 1742751 ] Workflow: User Choice is not working
if (resp.isHuman()) {
autoApproval = resp.getAD_User_ID() == Env.getAD_User_ID(getCtx());
if (!autoApproval && resp.getAD_User_ID() != 0)
setAD_User_ID(resp.getAD_User_ID());
} else if (resp.isRole()) {
MUserRoles[] urs = MUserRoles.getOfRole(getCtx(), resp.getAD_Role_ID());
for (int i = 0; i < urs.length; i++) {
if (urs[i].getAD_User_ID() == Env.getAD_User_ID(getCtx())) {
autoApproval = true;
break;
}
}
} else if (resp.isOrganization()) {
throw new AdempiereException("Support not implemented for " + resp);
} else {
throw new AdempiereException("@NotSupported@ " + resp);
}
// end MZ
}
if (autoApproval && doc.processIt(DocAction.ACTION_Approve) && doc.save())
// done
return true;
}
// wait for user
return false;
} else /****** User Form ******/
if (MWFNode.ACTION_UserForm.equals(action)) {
log.fine("Form:AD_Form_ID=" + m_node.getAD_Form_ID());
return false;
} else if (MWFNode.ACTION_SmartBrowse.equals(action)) {
log.fine("Form:AD_Browse_ID=" + m_node.getAD_Browse_ID());
return false;
} else /****** User Window ******/
if (MWFNode.ACTION_UserWindow.equals(action)) {
log.fine("Window:AD_Window_ID=" + m_node.getAD_Window_ID());
return false;
}
//
throw new IllegalArgumentException("Invalid Action (Not Implemented) =" + action);
}
use of org.compiere.model.MProcess in project adempiere by adempiere.
the class PayrollViaEMail method CreatePDF.
// sendIndividualMail
private File CreatePDF(int bPartnerId) {
File attachment = null;
int AD_Process_ID = reportProcessId;
MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, bPartnerId);
instance.saveEx();
ProcessInfo pi = new ProcessInfo("PH_SendEmail", AD_Process_ID);
pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
// Add Parameter - Selection=Y
MPInstancePara ip = new MPInstancePara(instance, 10);
ip.setParameter(X_HR_Process.COLUMNNAME_HR_Process_ID, payrollProcessId);
ip.saveEx();
pi.setRecord_ID(bPartnerId);
pi.setIsBatch(true);
MProcess worker = new MProcess(getCtx(), AD_Process_ID, get_TrxName());
worker.processIt(pi, Trx.get(get_TrxName(), true));
attachment = pi.getPDFReport();
return attachment;
}
use of org.compiere.model.MProcess in project adempiere by adempiere.
the class WLookup method doGet.
// init
/**
* Process the HTTP Get request - initial Start
* Needs to have parameters FormName and ColumnName
*
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
WebEnv.dump(request);
WebEnv.dump(request.getSession());
//Modified by Rob Klein 4/29/07
//
WebSessionCtx wsc = WebSessionCtx.get(request);
WWindowStatus ws = WWindowStatus.get(request);
if (wsc == null) {
WebUtil.createTimeoutPage(request, response, this, null);
return;
}
// Get Mandatory Parameters
String columnName = WebUtil.getParameter(request, "ColumnName");
//Lookup called from a process
//Modified by Rob Klein 4/29/07
int AD_Process_ID = WebUtil.getParameterAsInt(request, "AD_Process_ID");
//Lookup modified to include paging
//Modified by Rob Klein 07/07/07
int page = WebUtil.getParameterAsInt(request, "page");
log.info("This is the page on original call" + page);
if (AD_Process_ID > 0) {
if (AD_Process_ID < 1 || columnName == null || columnName.equals("")) {
WebUtil.createErrorPage(request, response, this, Msg.getMsg(wsc.ctx, "ParameterMissing"));
return;
}
String targetBase = "'" + columnName;
MProcess process = MProcess.get(wsc.ctx, AD_Process_ID);
MProcessPara para = null;
MProcessPara[] parameter = process.getParameters();
for (int i = 0; i < parameter.length; i++) {
para = parameter[i];
if (para.getColumnName().equals(columnName))
i = parameter.length;
}
// Create Document
WebDoc doc = WebDoc.createPopup(para.getColumnName());
div panel = new div();
panel.setStyle("height: 330px;overflow: scroll;overflow: auto;");
panel.addElement(fillTable(wsc, para.getColumnName(), para.getAD_Reference_Value_ID(), request.getRequestURI(), targetBase, false, page));
//tr tr = new tr().addElement(panel);
// Reset
String text = "Reset";
//if (wsc.ctx != null)
// text = Msg.getMsg (wsc.ctx, "Reset");
input resetbtn = new input("button", text, " " + text);
resetbtn.setID(text);
resetbtn.setClass("resetbtn");
String script = targetBase + "F.value='';" + targetBase + "D.value='';closePopup();";
resetbtn.setOnClick(script);
//
//
//First Page
text = "First";
//if (wsc.ctx != null)
// text = Msg.getMsg (wsc.ctx, "Next Page");
input firstpgbtn = new input(input.TYPE_BUTTON, text, " " + text);
firstpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", 1);return false;");
firstpgbtn.setID(text);
firstpgbtn.setClass("firstpgbtn");
//Previous Page
text = "Prior";
//if (wsc.ctx != null)
// text = Msg.getMsg (wsc.ctx, "Prior Page");
input prevpgbtn = new input(input.TYPE_BUTTON, text, " " + text);
int prevpage = (page == 1) ? 1 : page - 1;
prevpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + prevpage + ");return false;");
prevpgbtn.setID(text);
prevpgbtn.setClass("prevpgbtn");
//Next Page
text = "Next";
//if (wsc.ctx != null)
// text = Msg.getMsg (wsc.ctx, "Next Page");
input nextpgbtn = new input(input.TYPE_BUTTON, text, " " + text);
int nextpage = (page + 1);
nextpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + nextpage + ");return false;");
nextpgbtn.setID(text);
nextpgbtn.setClass("nextpgbtn");
//Last Page
text = "Next";
//if (wsc.ctx != null)
// text = Msg.getMsg (wsc.ctx, "Next Page");
input lastpgbtn = new input(input.TYPE_BUTTON, text, " " + text);
int lastpage = m_recordCount / MAX_LINES + 1;
lastpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + lastpage + ");return false;");
lastpgbtn.setID(text);
lastpgbtn.setClass("lastpgbtn");
int index1 = (page - 1) * MAX_LINES + 1;
int index2 = (page) * MAX_LINES < m_recordCount ? (page) * MAX_LINES : m_recordCount;
doc.getTable().addElement(new tr(new td(panel).setColSpan(2)));
doc.addPopupClose(ws.ctx)[0].addElement(" # " + index1 + "-" + index2 + " / " + m_recordCount).addElement(resetbtn).addElement(firstpgbtn).addElement(prevpgbtn).addElement(nextpgbtn).addElement(lastpgbtn);
WebUtil.createResponse(request, response, this, null, doc, false);
} else //Lookup called from a window
{
// Modified by Rob Klein 7/01/07
if (ws == null) {
WebUtil.createTimeoutPage(request, response, this, null);
return;
}
GridField mField = ws.curTab.getField(columnName);
log.config("ColumnName=" + columnName + ", MField=" + mField);
if (mField == null || columnName == null || columnName.equals("")) {
WebUtil.createErrorPage(request, response, this, Msg.getMsg(ws.ctx, "ParameterMissing"));
return;
}
// parent = framesetWindow
// Label - Dtata - Field - Button
String targetBase = "'" + columnName;
// Create Document
WebDoc doc = WebDoc.createPopup(mField.getHeader());
boolean hasDependents = ws.curTab.hasDependants(columnName);
boolean hasCallout = mField.getCallout().length() > 0;
div panel = new div();
panel.setStyle("height: 330px;overflow: scroll;overflow: auto;");
panel.addElement(fillTable(wsc, mField.getColumnName(), mField.getAD_Reference_Value_ID(), request.getRequestURI(), targetBase, hasDependents || hasCallout, page));
//tr tr = new tr().addElement(panel);
// Reset
String text = "Reset";
//if (wsc.ctx != null)
// text = Msg.getMsg (wsc.ctx, "Reset");
input resetbtn = new input(input.TYPE_RESET, text, " " + text);
resetbtn.setID(text);
resetbtn.setClass("resetbtn");
String script = targetBase + "F.value='';" + targetBase + "D.value='';self.close();";
if (hasDependents || hasCallout)
script += "startUpdate(" + targetBase + "F);";
resetbtn.setOnClick(script);
//First Page
text = "First";
//if (wsc.ctx != null)
// text = Msg.getMsg (wsc.ctx, "First");
input firstpgbtn = new input(input.TYPE_BUTTON, text, " " + text);
firstpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", 1);return false;");
firstpgbtn.setID(text);
firstpgbtn.setClass("firstpgbtn");
//Previous Page
text = "Prior";
//if (wsc.ctx != null)
// text = Msg.getMsg (wsc.ctx, "Prior");
input prevpgbtn = new input(input.TYPE_BUTTON, text, " " + text);
int prevpage = (page == 1) ? 1 : page - 1;
prevpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + prevpage + ");return false;");
prevpgbtn.setID(text);
prevpgbtn.setClass("prevpgbtn");
//Next Page
text = "Next";
//if (wsc.ctx != null)
// text = Msg.getMsg (wsc.ctx, "Next");
input nextpgbtn = new input(input.TYPE_BUTTON, text, " " + text);
int nextpage = (page + 1);
nextpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + nextpage + ");return false;");
nextpgbtn.setID(text);
nextpgbtn.setClass("nextpgbtn");
//Last Page
text = "Last";
//if (wsc.ctx != null)
// text = Msg.getMsg (wsc.ctx, "Last");
input lastpgbtn = new input(input.TYPE_BUTTON, text, " " + text);
int lastpage = m_recordCount / MAX_LINES + 1;
lastpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + lastpage + ");return false;");
lastpgbtn.setID(text);
lastpgbtn.setClass("lastpgbtn");
int index1 = (page - 1) * MAX_LINES + 1;
int index2 = (page) * MAX_LINES < m_recordCount ? (page) * MAX_LINES : m_recordCount;
doc.getTable().addElement(new tr(new td(panel).setColSpan(2)));
doc.addPopupClose(ws.ctx)[0].addElement(" # " + index1 + "-" + index2 + " / " + m_recordCount).addElement(resetbtn).addElement(firstpgbtn).addElement(prevpgbtn).addElement(nextpgbtn).addElement(lastpgbtn);
WebUtil.createResponse(request, response, this, null, doc, false);
}
}
use of org.compiere.model.MProcess in project adempiere by adempiere.
the class WProcess method createParameterPage.
// doPost
//Modified by Rob Klein 4/29/07
/**************************************************************************
* Create Parameter Page
* @param wsc web session context
* @param AD_Menu_ID Menu
* @return Page
*/
private WebDoc createParameterPage(WebSessionCtx wsc, int processId, int windowID, int tableID, int recordID, int Type, String columnName, GridTab mTab) {
MProcess process = null;
if (Type == 0)
process = MProcess.getFromMenu(wsc.ctx, processId);
else
process = MProcess.get(wsc.ctx, processId);
// need to check if Role can access
if (process == null) {
WebDoc doc = WebDoc.createWindow("Process Not Found");
return doc;
}
//Modified by Rob Klein 4/29/07
WebDoc doc = WebDoc.createWindow(process.getName());
if (process.isWorkflow()) {
//Modified by Rob Klein 7/01/07
if (mTab == null) {
doc = WebDoc.createWindow("No Tab found");
return doc;
}
// Pop up Document Action (Workflow)
if (columnName.toString().equals("DocAction")) {
readReference();
option[] Options = dynInit(windowID, tableID, recordID, columnName, mTab);
td center = doc.addWindowCenter(false);
WebField wField = new WebField(wsc, columnName, columnName, columnName, // no display length
17, 22, 22, false, // not r/o, ., not error, not dependent
false, false, false, false, false, processId, 0, 0, 0, 0, null, null, null, null, null);
if (process.getDescription() != null)
center.addElement(new p(new i(process.getDescription())));
if (process.getHelp() != null)
center.addElement(new p(process.getHelp(), AlignType.LEFT));
form myForm = new form("WProcess").setName("process" + process.getAD_Process_ID());
myForm.setTarget("WPopup");
//myForm.setOnSubmit("this.Submit.disabled=true;return true;");
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Process_ID", process.getAD_Process_ID()));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Window_ID", windowID));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Table_ID", tableID));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Record_ID", recordID));
table myTable = new table("0", "0", "5", "100%", null);
myTable.setID("WProcessParameter");
myTable.addElement(new tr().addElement(wField.getLabel()).addElement(createSelectField(columnName, Options)));
// Reset
String text = "Reset";
if (wsc.ctx != null)
text = Msg.getMsg(wsc.ctx, "Reset");
input restbtn = new input(input.TYPE_RESET, text, " " + text);
restbtn.setID(text);
restbtn.setClass("resetbtn");
// Submit
text = "Submit";
if (wsc.ctx != null)
text = Msg.getMsg(wsc.ctx, "Submit");
input submitbtn = new input(input.TYPE_SUBMIT, text, " " + text);
submitbtn.setID(text);
submitbtn.setClass("submitbtn");
myTable.addElement(new tr().addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, restbtn)).addElement(new td(null, AlignType.LEFT, AlignType.MIDDLE, false, submitbtn)).addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, null)));
myForm.addElement(myTable);
center.addElement(myForm);
}
// DocAction
} else {
td center = doc.addWindowCenter(false);
if (process.getDescription() != null)
center.addElement(new p(new i(process.getDescription())));
if (process.getHelp() != null)
center.addElement(new p(process.getHelp(), AlignType.LEFT));
//
form myForm = new form("WProcess").setName("process" + process.getAD_Process_ID());
myForm.setTarget("WPopup");
//myForm.setOnSubmit("this.Submit.disabled=true;return true;");
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Process_ID", process.getAD_Process_ID()));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Window_ID", windowID));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Table_ID", tableID));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Record_ID", recordID));
table myTable = new table("0", "0", "5", "100%", null);
myTable.setID("WProcessParameter");
MProcessPara[] parameter = process.getParameters();
for (int i = 0; i < parameter.length; i++) {
MProcessPara para = parameter[i];
WebField wField = new WebField(wsc, para.getColumnName(), para.getName(), para.getDescription(), // no display length
para.getAD_Reference_ID(), para.getFieldLength(), para.getFieldLength(), false, // not r/o, ., not error, not dependent
false, para.isMandatory(), false, false, false, para.getAD_Process_ID(), 0, 0, 0, i, null, null, null, null, null);
WebField wFieldforRange = null;
if (para.isRange())
wFieldforRange = new WebField(wsc, para.getColumnName(), para.getName(), para.getDescription(), // no display length
para.getAD_Reference_ID(), para.getFieldLength(), para.getFieldLength(), false, // not r/o, ., not error, not dependent
false, para.isMandatory(), false, false, false, para.getAD_Process_ID(), 0, 0, 0, i + 1, null, null, null, null, null);
td toField = para.isRange() ? wFieldforRange.getField(para.getLookup(), para.getDefaultValue2()) : new td(WebEnv.NBSP);
// Add to Table
myTable.addElement(new tr().addElement(wField.getLabel()).addElement(wField.getField(para.getLookup(), para.getDefaultValue())).addElement(toField));
}
// Reset
String text = "Reset";
if (wsc.ctx != null)
text = Msg.getMsg(wsc.ctx, "Reset");
input restbtn = new input(input.TYPE_RESET, text, " " + text);
restbtn.setID(text);
restbtn.setClass("resetbtn");
// Submit
text = "Submit";
if (wsc.ctx != null)
text = Msg.getMsg(wsc.ctx, "Submit");
input submitbtn = new input(input.TYPE_SUBMIT, text, " " + text);
submitbtn.setID(text);
submitbtn.setClass("submitbtn");
submitbtn.setOnClick("popUp('WProcess','WPopup')");
myTable.addElement(new tr().addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, restbtn)).addElement(new td(null, AlignType.LEFT, AlignType.MIDDLE, false, submitbtn)).addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, null)));
myForm.addElement(myTable);
center.addElement(myForm);
}
return doc;
}
Aggregations