You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Arjun Dhar <dh...@yahoo.com> on 2010/07/22 16:19:55 UTC

How to autogenerate WebPage classes for static pages?

Hi,
 a section of my website is static pages (template) but no need of injecting
any components 
[I prefer getting as much dine through inheritance cleanly over Panels].

Each markup has to have a corresponding WebPage in wicket. 
I'm exploring the ASM library with CGLIB to auto generate classes for static
templates ...is there any wicket way of doing this already? 

..or if someone has a Wicket way or even the CGLIB/JAVASSIST/ASM code ready
to go, I'd appreciate it.

thanks
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-autogenerate-WebPage-classes-for-static-pages-tp2298749p2298749.html
Sent from the Wicket - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to autogenerate WebPage classes for static pages?

Posted by Igor Vaynberg <ig...@gmail.com>.
no need for multiple page classes

class contentpage extends basepage {
  public contentpage(final pageparameters params) {
    add(new label("content", new loadabledetachablemodel() {
       public object load() {
          return loadcontentfromtemplate(params.get("template"));
       }}}}

then mount the page, lets say on "/content" and generate urls to it using
urlfor(contentpage.class, new pageparameters("template=foo"))
which will generate a url like this: /content/template/foo with the
default coding strategy

-igor


On Thu, Jul 22, 2010 at 7:19 AM, Arjun Dhar <dh...@yahoo.com> wrote:
>
> Hi,
>  a section of my website is static pages (template) but no need of injecting
> any components
> [I prefer getting as much dine through inheritance cleanly over Panels].
>
> Each markup has to have a corresponding WebPage in wicket.
> I'm exploring the ASM library with CGLIB to auto generate classes for static
> templates ...is there any wicket way of doing this already?
>
> ..or if someone has a Wicket way or even the CGLIB/JAVASSIST/ASM code ready
> to go, I'd appreciate it.
>
> thanks
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-autogenerate-WebPage-classes-for-static-pages-tp2298749p2298749.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to autogenerate WebPage classes for static pages?

Posted by Arjun Dhar <dh...@yahoo.com>.
Hi Martin,
 thanks. the tip was insightful.  though am confused about one point.
So the examples load resources via "WebApplication". While your suggestion
seems to point towards WebPage. As in the code below, I've inserted the
MARKUP of the child page ..but then that is no inheritance. Is this what you
meant or something else?


/**
 * Principle<br />
 * Represent All generic Static pages (in a template) without the need to
build
 * a class for each Page explicitly.<br />
 * This class will intercept the actual intended path
(<code>getRequest().getPath()</code>)
 * and then load the appropriate intended static resource.<br />
 * Note: The page extends TemplatePage which defines a common template for
the static pages
 * , which may be a descendant of {@link WebPage}.<br /><br />
 * 
 * Flow<br />
 * This class is invoked by the class that extends {@link
WebApplication}.init();
 * by Mount-ing it:<br />
 * <code>mount(new IndexedParamUrlCodingStrategy("/path/to/staticpages",
GenericStaticPage.class));</code><br />
 * On getting control, it delegates it to the appropriate resource as
described by principle.<br /><br />
 * 
 * 
 * @see
http://apache-wicket.1842946.n4.nabble.com/How-to-autogenerate-WebPage-classes-for-static-pages-td2298749.html#a2298749 
 * @author arjun_dhar
 */
public class GenericStaticPage extends TemplatePage { //All static pages
following a particular template
	private Logger log = LoggerFactory.getLogger(GenericStaticPage.class);
//sl4j logger
	
	public GenericStaticPage() throws MalformedURLException {
		String pageUrl = getRequest().getPath();
		log.info("Requested page" + pageUrl);
		
		//Extract Resource name from path
		String resName = pageUrl.substring(pageUrl.lastIndexOf('/'),
pageUrl.length());		
		
		//Load resource
		String resourceName = "/html/"+resName;
		log.info("Resource Name = " + resourceName);
		URL url = ((WebApplication)
getApplication()).getServletContext().getResource(resourceName);
		log.info("Resource URL = " + url.toString());
        add(new Include("childPageInsert", url.toString())); 		
	}
}

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-autogenerate-WebPage-classes-for-static-pages-tp2298749p2300505.html
Sent from the Wicket - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to autogenerate WebPage classes for static pages?

Posted by Martin Grigorov <mg...@apache.org>.
I'd use a WebPage with custom template loading (see
http://wicketstuff.org/wicket14/customresourceloading/)
Mount this page for all URLs with static data.

Then the current URL can be found with
String pageUrl = getRequest().getPath();

load the appropriate .html depending on 'pageUrl'.

On Thu, Jul 22, 2010 at 4:19 PM, Arjun Dhar <dh...@yahoo.com> wrote:

>
> Hi,
>  a section of my website is static pages (template) but no need of
> injecting
> any components
> [I prefer getting as much dine through inheritance cleanly over Panels].
>
> Each markup has to have a corresponding WebPage in wicket.
> I'm exploring the ASM library with CGLIB to auto generate classes for
> static
> templates ...is there any wicket way of doing this already?
>
> ..or if someone has a Wicket way or even the CGLIB/JAVASSIST/ASM code ready
> to go, I'd appreciate it.
>
> thanks
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-autogenerate-WebPage-classes-for-static-pages-tp2298749p2298749.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>