Foo.class.newInstance() will use zero arg constructor which is not possible because panel has no zero arg. constructor so basically you got the exception at that line itself :)
just pass the panel id in screen method and one enum which helps you in identifying the panel type you want to create and then create a panel instance in a normal way etc. what you want to do.. On Sun, Mar 27, 2011 at 12:56 PM, Mansour Al Akeel <[email protected]> wrote: > Martin, > I could not find any help using this extension. May be I missed something > somewhere. > Let's look at a peice of code of what I am trying to do: > > private void setScreen(String screen) { > try { > Panel myPanel; > myPanel = (Panel) > Class.forName("com.mycompany.components."+screen).newInstance(); > screenPanel.replaceWith(myPanel); > } catch (InstantiationException e) { > e.printStackTrace(); > } catch (IllegalAccessException e) { > e.printStackTrace(); > } catch (ClassNotFoundException e) { > e.printStackTrace(); > } > } > > So assuming I need to display a screen called "EditUserScreen", I need > to load > > myPanel = (Panel) > Class.forName("com.mycompany.components.EditUserScreen").newInstance(); > > With the above code everything works fine. But Nothing is replaced. I > mean it executes with with no error, but the new panel is not shown. One > more thing to mention, if I add additional components in the > EditUserScreen Panel class, without adding them in the html, I see NO > error generated ! Is't correct to conclude that the html template for > EditUserScreen is never parsed, and instead the Panle.java is used ? > Shouldn't the old panel should be removed in this case, at least? > > > On Fri Mar 25,2011 03:06 pm, Mansour Al Akeel wrote: >> Thank you Martin, >> I had a quick look at extension. I will try a small application with it >> soon. However my requirement are a bit more complex, as I need to load >> Panels by string. So let's say I have a String called "EditUserScreen", >> then I need to dynamically load this panel. I am not sure yet if the >> wizard extension can do this, but will try it anyway. >> If you know something else that can work for these requirements please >> advice me. >> >> >> >> On Fri Mar 25,2011 12:37 pm, Martin Grigorov wrote: >> > See Wizard component in wicket-extensions. >> > You'll need custom logic to check whether the previous/next wizard step >> > should be shown to the current user depending on its privileges. >> > >> > On Fri, Mar 25, 2011 at 1:57 AM, Mansour Al Akeel >> > <[email protected] >> > > wrote: >> > >> > > I do have the need to implement different screens. Each screen is a >> > > Panel that will be displayed when requested from the screens menu. >> > > >> > > The screen menu should display the items depending on the functionality >> > > the user has access to. >> > > >> > > Can some one point me to an article or a tutorial with similar >> > > requirements ? >> > > >> > > I trully appreciate any help. >> > > >> > > >> > > >> > > >> > > --------------------------------------------------------------------- >> > > To unsubscribe, e-mail: [email protected] >> > > For additional commands, e-mail: [email protected] >> > > >> > > >> > >> > >> > -- >> > Martin Grigorov >> > jWeekend >> > Training, Consulting, Development >> > http://jWeekend.com <http://jweekend.com/> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- thank you, regards, Vineet Semwal --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
