@@ -105,19 +105,43 @@ public boolean isAjaxCallMode()
105105 public void addString (String value ) {
106106 httpContext .GX_webresponse .addString (value );
107107 }
108-
108+
109109 public GXMasterPage createMasterPage (int remoteHandle , String fullClassName ) {
110- fullClassName = fullClassName + "_impl" ;
110+
111+ String masterPage = this .context .getPreferences ().getProperty ("MasterPage" , "" );
112+ if (fullClassName .equals ("(default)" )) // Is the default
113+ {
114+ if (masterPage .isEmpty ())
115+ {
116+ logger .error ("The default master page is not present on the client.cfg file, please add the MasterPage key to the client.cfg." );
117+ return null ;
118+ }
119+ String namespace = this .context .getPreferences ().getProperty ("NAME_SPACE" , "" );
120+ fullClassName = namespace .isEmpty () ? masterPage .toLowerCase () + "_impl" : namespace .trim () + "." + masterPage .toLowerCase () + "_impl" ;
121+ }
122+ if (fullClassName .equals ("(none)" )) // none Master Page
123+ {
124+ return new NoneMasterPage ((HttpContext ) this .context .getHttpContext ());
125+ }
126+ else {
127+ fullClassName = fullClassName + "_impl" ;
128+ }
111129 try {
112130 Class <?> masterPageClass = Class .forName (fullClassName );
113131 return (GXMasterPage ) masterPageClass .getConstructor (new Class <?>[] {int .class , ModelContext .class }).newInstance (remoteHandle , context .copy ());
114132 } catch (ClassNotFoundException e ) {
115- logger .error ("MasterPage class not found: " + fullClassName , e );
116- throw new RuntimeException (e );
117- } catch (Exception e ) {
118- logger .error ("MasterPage could not be loaded: " + fullClassName , e );
119- throw new RuntimeException (e );
133+ logger .error ("MasterPage not found: " + fullClassName );
134+ e .printStackTrace ();
135+ } catch (IllegalAccessException e ) {
136+ e .printStackTrace ();
137+ } catch (InstantiationException e ) {
138+ e .printStackTrace ();
139+ } catch (NoSuchMethodException e ) {
140+ e .printStackTrace ();
141+ } catch (InvocationTargetException e ) {
142+ e .printStackTrace ();
120143 }
144+ return null ;
121145 }
122146
123147
@@ -128,25 +152,20 @@ protected Object dyncall(String MethodName)
128152 logger .error ("DynCall - Method not found: " + MethodName );
129153 return null ;
130154 }
131-
132155 Class [] pars = m .getParameterTypes ();
133156 int ParmsCount = pars .length ;
134157 Object [] convertedparms = new Object [ParmsCount ];
135-
136- for (int i = 0 ; i < ParmsCount ; i ++) {
158+ for (int i = 0 ; i < ParmsCount ; i ++)
137159 convertedparms [i ] = convertparm (pars , i , WebUtils .decryptParm (httpContext .GetNextPar (), "" ));
138- }
139-
140160 try
141161 {
142162 return m .invoke (this , convertedparms );
143163 }
144164 catch (java .lang .Exception e )
145165 {
146166 logger .error ("DynCall - Invoke error " + MethodName , e );
167+ return null ;
147168 }
148-
149- return null ;
150169 }
151170
152171 protected Object convertparm (Class <?>[] pars , int i , Object value ) {
0 commit comments