Skip to content

Troubleshooting: Add better detail exception message when Masterpage cannot be loaded #613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
47 changes: 14 additions & 33 deletions java/src/main/java/com/genexus/webpanels/GXWebPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,43 +100,19 @@ public boolean isAjaxCallMode()
public void addString(String value) {
httpContext.GX_webresponse.addString(value);
}

public GXMasterPage createMasterPage(int remoteHandle, String fullClassName) {

String masterPage = this.context.getPreferences().getProperty("MasterPage", "");
if (fullClassName.equals("(default)")) // Is the default
{
if (masterPage.isEmpty())
{
logger.error("The default master page is not present on the client.cfg file, please add the MasterPage key to the client.cfg.");
return null;
}
String namespace = this.context.getPreferences().getProperty("NAME_SPACE", "");
fullClassName = namespace.isEmpty() ? masterPage.toLowerCase() + "_impl" : namespace.trim() + "." + masterPage.toLowerCase() + "_impl";
}
if (fullClassName.equals("(none)")) // none Master Page
{
return new NoneMasterPage((HttpContext) this.context.getHttpContext());
}
else{
fullClassName = fullClassName + "_impl";
}
fullClassName = fullClassName + "_impl";
try {
Class<?> masterPageClass = Class.forName(fullClassName);
return (GXMasterPage) masterPageClass.getConstructor(new Class<?>[] {int.class, ModelContext.class}).newInstance(remoteHandle, context.copy());
} catch (ClassNotFoundException e) {
logger.error("MasterPage not found: " + fullClassName);
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
logger.error("MasterPage class not found: " + fullClassName, e);
throw new RuntimeException(e);
} catch (Exception e) {
logger.error("MasterPage could not be loaded: " + fullClassName, e);
throw new RuntimeException(e);
}
return null;
}


Expand All @@ -147,20 +123,25 @@ protected Object dyncall(String MethodName)
logger.error("DynCall - Method not found: " + MethodName);
return null;
}

Class[] pars = m.getParameterTypes();
int ParmsCount = pars.length;
Object[] convertedparms = new Object[ParmsCount];
for (int i = 0; i < ParmsCount; i++)

for (int i = 0; i < ParmsCount; i++) {
convertedparms[i] = convertparm(pars, i, WebUtils.decryptParm(httpContext.GetNextPar(), ""));
}

try
{
return m.invoke(this, convertedparms);
}
catch (java.lang.Exception e)
{
logger.error("DynCall - Invoke error " + MethodName, e);
return null;
}

return null;
}

protected Object convertparm(Class<?>[] pars, int i, Object value) {
Expand Down