IDEMPIERE-2361 Add a method to generate URL for action zoom
This commit is contained in:
parent
44f99b45bc
commit
655347bd32
|
@ -67,9 +67,7 @@ import org.compiere.model.MAttachmentEntry;
|
|||
import org.compiere.model.MMailMsg;
|
||||
import org.compiere.model.MRequest;
|
||||
import org.compiere.model.MStore;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.model.MUserMail;
|
||||
import org.compiere.model.PO;
|
||||
|
||||
/**
|
||||
* Servlet Utilities
|
||||
|
@ -1317,45 +1315,4 @@ public final class WebUtil
|
|||
return retVal;
|
||||
}
|
||||
|
||||
/** Return the host name of the server (eg: demo.idempiere.com) */
|
||||
public static String getHostName() {
|
||||
StringBuilder retValue = new StringBuilder();
|
||||
|
||||
try {
|
||||
retValue.append(InetAddress.getLocalHost().getHostName());
|
||||
} catch (UnknownHostException e) {
|
||||
log.log(Level.WARNING, "Local host or IP not found", e);
|
||||
retValue.append(getHostIP());
|
||||
}
|
||||
return retValue.toString();
|
||||
}
|
||||
|
||||
/** Return the hardcoded link to the login page */
|
||||
public static String getLoginPage() {
|
||||
return getHostName() + "/webui/index.zul";
|
||||
}
|
||||
|
||||
/** Return the link for direct access to the record using tableID */
|
||||
public static String getZoomUrlTableID(PO po)
|
||||
{
|
||||
return getApplicationUrl(po) + "?Action=Zoom&AD_Table_ID=" + po.get_Table_ID() + "&Record_ID=" + po.get_ID();
|
||||
}
|
||||
|
||||
/** Return the link for direct access to the record using tablename */
|
||||
public static String getZoomUrlTableName(PO po)
|
||||
{
|
||||
return getApplicationUrl(po) + "?Action=Zoom&TableName" + po.get_TableName() + "&Record_ID=" + po.get_ID();
|
||||
}
|
||||
|
||||
/** Return the link to the login page */
|
||||
public static String getApplicationUrl(PO po)
|
||||
{
|
||||
String url = MSysConfig.getValue("APPLICATION_URL", po.getAD_Client_ID());
|
||||
|
||||
if (!Util.isEmpty(url) && !url.equals("USE_HARDCODED"))
|
||||
return MSysConfig.getValue("APPLICATION_URL", po.getAD_Client_ID());
|
||||
else
|
||||
return getLoginPage();
|
||||
}
|
||||
|
||||
} // WebUtil
|
||||
|
|
|
@ -54,8 +54,10 @@ import org.compiere.model.MLookup;
|
|||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MSession;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.MZoomCondition;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.CacheMgt;
|
||||
|
@ -64,6 +66,7 @@ import org.compiere.util.DisplayType;
|
|||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.Language;
|
||||
import org.compiere.util.Util;
|
||||
import org.zkoss.web.servlet.Servlets;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Desktop;
|
||||
|
@ -806,4 +809,35 @@ public final class AEnv
|
|||
}
|
||||
return fLanguageType;
|
||||
}
|
||||
|
||||
private static String m_ApplicationUrl = null;
|
||||
public static String getApplicationUrl() {
|
||||
String url = MSysConfig.getValue("APPLICATION_URL", Env.getAD_Client_ID(Env.getCtx()));
|
||||
if (!Util.isEmpty(url) && !url.equals("USE_HARDCODED"))
|
||||
return MSysConfig.getValue("APPLICATION_URL", Env.getAD_Client_ID(Env.getCtx()));
|
||||
if (m_ApplicationUrl != null)
|
||||
return m_ApplicationUrl;
|
||||
int port = Executions.getCurrent().getServerPort();
|
||||
String sch = Executions.getCurrent().getScheme();
|
||||
String sport = null;
|
||||
if ( (sch.equals("http") && port == 80) || (sch.equals("https") && port == 443) )
|
||||
sport = "";
|
||||
else
|
||||
sport = ":" + port;
|
||||
m_ApplicationUrl = sch + "://" + Executions.getCurrent().getServerName() + sport + Executions.getCurrent().getContextPath() + Executions.getCurrent().getDesktop().getRequestPath();
|
||||
return m_ApplicationUrl;
|
||||
}
|
||||
|
||||
/** Return the link for direct access to the record using tableID */
|
||||
public static String getZoomUrlTableID(PO po)
|
||||
{
|
||||
return getApplicationUrl() + "?Action=Zoom&AD_Table_ID=" + po.get_Table_ID() + "&Record_ID=" + po.get_ID();
|
||||
}
|
||||
|
||||
/** Return the link for direct access to the record using tablename */
|
||||
public static String getZoomUrlTableName(PO po)
|
||||
{
|
||||
return getApplicationUrl() + "?Action=Zoom&TableName" + po.get_TableName() + "&Record_ID=" + po.get_ID();
|
||||
}
|
||||
|
||||
} // AEnv
|
||||
|
|
Loading…
Reference in New Issue