You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Vika <Vi...@nasa.gov> on 2009/02/11 17:45:30 UTC

how to give static pages consistant look with wicket - partial repeat

I am looking at wicket trying to decide if i would want to use it for my
project.
Currently I am struggling trying to give static and dynamic pages consistent
look with wicket without using sitemesh.  I was able to get wicket
application to direct all static page requests to my wicket StaticPage that
would read the content of a file and add it to the page as MultiLineLabel.
However my problem is that i don't want to add whole html file. I need to
extract the content of <title>, <body> and <meta> tags and add these
separately. Is there anything in api or any examples i should look at ?

Please see the code below. 

in Aplication.java  init()

mount(new URIRequestTargetUrlCodingStrategy("/docs")
        {
            @Override
            public IRequestTarget decode(RequestParameters
requestParameters)
            {
                String path = "/app/" + getURI(requestParameters);
                return new PageRequestTarget(new StaticPage(new
WebExternalResourceRequestTarget(path)));
            }
        });
----------------------------------------------------------------------------------------------------------------------------------------------------------------
in StaicPage.java
public class StaticPage extends BasePage implements AuthenticatedWebPage
{
        public StaticPage(WebExternalResourceRequestTarget staticResource)
        {
                String staticResourceContent = "";
                try {
                        staticResourceContent =
                          
convertStreamToString(staticResource.getResourceStream().getInputStream());
                } catch (ResourceStreamNotFoundException e)
                {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                add(new MultiLineLabel("staticContent",
staticResourceContent));
        }
}
---------------------------------------------------------------------------------------------------------------------------
Here is what i get in the browser when click on static link:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
this is a test
</body>
</html>
This is in the footer
--------------------------------------------------------------------------------------------------

Another variation of StaticPage.java i tried was
public class StaticPage extends BasePage implements AuthenticatedWebPage
{
	public StaticPage(WebExternalResourceRequestTarget staticResource)
	{
                MarkupResourceStream markupStream = 
			new MarkupResourceStream(staticResource.getResourceStream());
		
		
		MarkupParser parser = new MarkupParser(markupStream);

		Markup markup = parser.parse();

However I got stuck at this point since i still don't see a way of getting
individual html tags from Markup


thank you in advance, 

Vicky

-- 
View this message in context: http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p21958254.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 give static pages consistant look with wicket - partial repeat

Posted by Martijn Dashorst <ma...@gmail.com>.
On Thu, Feb 12, 2009 at 4:18 PM, Vika <Vi...@nasa.gov> wrote:
> This works great! I have a few of questions:
> 1) Why do you use <wicket:container wicket:id="content"> ? If i replace
> wicket:container with span seems to work the same. Is there a place i can
> read about the usage of all the wicket tags like wicket:container,
> wicket:link etc... ?

http://letmegooglethatforyou.com/?q=%22wicket%3Acontainer%22

-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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


Re: how to give static pages consistant look with wicket - partial repeat

Posted by Vika <Vi...@nasa.gov>.
Igor, 

This works great! I have a few of questions:
1) Why do you use <wicket:container wicket:id="content"> ? If i replace
wicket:container with span seems to work the same. Is there a place i can
read about the usage of all the wicket tags like wicket:container,
wicket:link etc... ?

2) With sitemesh i put info  like section and subsection in META tags of
each page.  Then the decorator template can access that info to display the
navigation correctly. What would be the best way to accomplish this in
wicket with static pages ? One way i see is to have file name contain
section and subsection info. Is there a better way ?

3) The code you provided works correctly if
MyBasePageWithDecoratingMarkup.html doesn't have a title tag. Then the
decorated page gets the title from the static page. However if
MyBasePageWithDecoratingMarkup.html has a default title 
 then the title from the static page is not displayed. Any suggestions ?

thanks

Vicky


igor.vaynberg wrote:
> 
> all you have to do is this:
> 
> mount(new indexedparamcodingstrategy("/static", StaticPage.class));
> 
> class staticpage extends MyBasePageWithDecoratingMarkup {
>   private final String resource;
>   public staticpage(PageParameters params) {
>     resource=params.get("0");
>     add(new Label("content", new PropertyModel(this,
> "content")).setEscapeModelStrings(false));
>   }
> 
>   public String getContent() {
>      // load the resource content however you want
>      InputStream is=new FileInputStream(basePath+"/"+resource);
>      try {
>         return Streams.readIntoString(is);
>      } finally { is.close(); }
>   }
> }
> 
> static.page.html: [wicket:extend][wicket:container
> wicket:id="content"]content will be
> here[/wicket:container][/wicket:extend]
> 
> then if you go to /static/myfile.html the contents of myfile.html will
> be shown within your decorated page
> 
> -igor
> 
> On Wed, Feb 11, 2009 at 8:45 AM, Vika <Vi...@nasa.gov> wrote:
>>
>> I am looking at wicket trying to decide if i would want to use it for my
>> project.
>> Currently I am struggling trying to give static and dynamic pages
>> consistent
>> look with wicket without using sitemesh.  I was able to get wicket
>> application to direct all static page requests to my wicket StaticPage
>> that
>> would read the content of a file and add it to the page as
>> MultiLineLabel.
>> However my problem is that i don't want to add whole html file. I need to
>> extract the content of <title>, <body> and <meta> tags and add these
>> separately. Is there anything in api or any examples i should look at ?
>>
>> Please see the code below.
>>
>> in Aplication.java  init()
>>
>> mount(new URIRequestTargetUrlCodingStrategy("/docs")
>>        {
>>            @Override
>>            public IRequestTarget decode(RequestParameters
>> requestParameters)
>>            {
>>                String path = "/app/" + getURI(requestParameters);
>>                return new PageRequestTarget(new StaticPage(new
>> WebExternalResourceRequestTarget(path)));
>>            }
>>        });
>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
>> in StaicPage.java
>> public class StaticPage extends BasePage implements AuthenticatedWebPage
>> {
>>        public StaticPage(WebExternalResourceRequestTarget staticResource)
>>        {
>>                String staticResourceContent = "";
>>                try {
>>                        staticResourceContent =
>>
>> convertStreamToString(staticResource.getResourceStream().getInputStream());
>>                } catch (ResourceStreamNotFoundException e)
>>                {
>>                        // TODO Auto-generated catch block
>>                        e.printStackTrace();
>>                }
>>                add(new MultiLineLabel("staticContent",
>> staticResourceContent));
>>        }
>> }
>> ---------------------------------------------------------------------------------------------------------------------------
>> Here is what i get in the browser when click on static link:
>>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>> "http://www.w3.org/TR/html4/loose.dtd">
>> <html>
>> <head>
>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>> <title>Insert title here</title>
>> </head>
>> <body>
>> this is a test
>> </body>
>> </html>
>> This is in the footer
>> --------------------------------------------------------------------------------------------------
>>
>> Another variation of StaticPage.java i tried was
>> public class StaticPage extends BasePage implements AuthenticatedWebPage
>> {
>>        public StaticPage(WebExternalResourceRequestTarget staticResource)
>>        {
>>                MarkupResourceStream markupStream =
>>                        new
>> MarkupResourceStream(staticResource.getResourceStream());
>>
>>
>>                MarkupParser parser = new MarkupParser(markupStream);
>>
>>                Markup markup = parser.parse();
>>
>> However I got stuck at this point since i still don't see a way of
>> getting
>> individual html tags from Markup
>>
>>
>> thank you in advance,
>>
>> Vicky
>>
>> --
>> View this message in context:
>> http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p21958254.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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p21978076.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 give static pages consistant look with wicket - partial repeat

Posted by Vika <Vi...@nasa.gov>.
Actually images work now if i don't put them under /app. That was my mistake.
Thank you for your help!


igor.vaynberg wrote:
> 
> what happens when you paste the url of the image directly into the
> browser's address bar?
> 
> this wouldnt be wicket finding or rendering the images, they would be
> served directly by the servlet container.
> 
> -igor
> 
> On Tue, Mar 3, 2009 at 7:46 AM, Vika <Vi...@nasa.gov> wrote:
>>
>> I am having the same problem!
>>
>>
>> matrixguy wrote:
>>>
>>> Hi,
>>>
>>> The following code worked very nicely with the text in the HTML file,
>>> but
>>> it's not working with the embedded images in the HTML file. I have
>>> verified that wicket can find the images (so it's not the path issue for
>>> the images). It's as if wicket can find the images but not able to
>>> render
>>> them. :( Any ideas?
>>>
>>> Thanks.
>>>
>>>
>>>
>>>
>>> igor.vaynberg wrote:
>>>>
>>>> all you have to do is this:
>>>>
>>>> mount(new indexedparamcodingstrategy("/static", StaticPage.class));
>>>>
>>>> class staticpage extends MyBasePageWithDecoratingMarkup {
>>>>   private final String resource;
>>>>   public staticpage(PageParameters params) {
>>>>     resource=params.get("0");
>>>>     add(new Label("content", new PropertyModel(this,
>>>> "content")).setEscapeModelStrings(false));
>>>>   }
>>>>
>>>>   public String getContent() {
>>>>      // load the resource content however you want
>>>>      InputStream is=new FileInputStream(basePath+"/"+resource);
>>>>      try {
>>>>         return Streams.readIntoString(is);
>>>>      } finally { is.close(); }
>>>>   }
>>>> }
>>>>
>>>> static.page.html: [wicket:extend][wicket:container
>>>> wicket:id="content"]content will be
>>>> here[/wicket:container][/wicket:extend]
>>>>
>>>> then if you go to /static/myfile.html the contents of myfile.html will
>>>> be shown within your decorated page
>>>>
>>>> -igor
>>>>
>>>> On Wed, Feb 11, 2009 at 8:45 AM, Vika <Vi...@nasa.gov>
>>>> wrote:
>>>>>
>>>>> I am looking at wicket trying to decide if i would want to use it for
>>>>> my
>>>>> project.
>>>>> Currently I am struggling trying to give static and dynamic pages
>>>>> consistent
>>>>> look with wicket without using sitemesh.  I was able to get wicket
>>>>> application to direct all static page requests to my wicket StaticPage
>>>>> that
>>>>> would read the content of a file and add it to the page as
>>>>> MultiLineLabel.
>>>>> However my problem is that i don't want to add whole html file. I need
>>>>> to
>>>>> extract the content of <title>, <body> and <meta> tags and add these
>>>>> separately. Is there anything in api or any examples i should look at
>>>>> ?
>>>>>
>>>>> Please see the code below.
>>>>>
>>>>> in Aplication.java  init()
>>>>>
>>>>> mount(new URIRequestTargetUrlCodingStrategy("/docs")
>>>>>        {
>>>>>            @Override
>>>>>            public IRequestTarget decode(RequestParameters
>>>>> requestParameters)
>>>>>            {
>>>>>                String path = "/app/" + getURI(requestParameters);
>>>>>                return new PageRequestTarget(new StaticPage(new
>>>>> WebExternalResourceRequestTarget(path)));
>>>>>            }
>>>>>        });
>>>>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
>>>>> in StaicPage.java
>>>>> public class StaticPage extends BasePage implements
>>>>> AuthenticatedWebPage
>>>>> {
>>>>>        public StaticPage(WebExternalResourceRequestTarget
>>>>> staticResource)
>>>>>        {
>>>>>                String staticResourceContent = "";
>>>>>                try {
>>>>>                        staticResourceContent =
>>>>>
>>>>> convertStreamToString(staticResource.getResourceStream().getInputStream());
>>>>>                } catch (ResourceStreamNotFoundException e)
>>>>>                {
>>>>>                        // TODO Auto-generated catch block
>>>>>                        e.printStackTrace();
>>>>>                }
>>>>>                add(new MultiLineLabel("staticContent",
>>>>> staticResourceContent));
>>>>>        }
>>>>> }
>>>>> ---------------------------------------------------------------------------------------------------------------------------
>>>>> Here is what i get in the browser when click on static link:
>>>>>
>>>>> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>>>> "http://www.w3.org/TR/html4/loose.dtd">
>>>>> <html>
>>>>> <head>
>>>>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>>>>> <title>Insert title here</title>
>>>>> </head>
>>>>> <body>
>>>>> this is a test
>>>>> </body>
>>>>> </html>
>>>>> This is in the footer
>>>>> --------------------------------------------------------------------------------------------------
>>>>>
>>>>> Another variation of StaticPage.java i tried was
>>>>> public class StaticPage extends BasePage implements
>>>>> AuthenticatedWebPage
>>>>> {
>>>>>        public StaticPage(WebExternalResourceRequestTarget
>>>>> staticResource)
>>>>>        {
>>>>>                MarkupResourceStream markupStream =
>>>>>                        new
>>>>> MarkupResourceStream(staticResource.getResourceStream());
>>>>>
>>>>>
>>>>>                MarkupParser parser = new MarkupParser(markupStream);
>>>>>
>>>>>                Markup markup = parser.parse();
>>>>>
>>>>> However I got stuck at this point since i still don't see a way of
>>>>> getting
>>>>> individual html tags from Markup
>>>>>
>>>>>
>>>>> thank you in advance,
>>>>>
>>>>> Vicky
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p21958254.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
>>>>
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p22311189.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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p22314209.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 give static pages consistant look with wicket - partial repeat

Posted by Igor Vaynberg <ig...@gmail.com>.
you need to rewrite image paths in the static url to conform to your
server setup.

-igor

On Tue, Mar 3, 2009 at 12:30 PM, matrixguy <pe...@hotmail.com> wrote:
>
> Hi Igor,
>
> I am having problems with loading images. I have the following directory
> structure:
>
> -web
> --staticpages
> ----help.html
> ----image.gif
> --scripts
> and so on...
>
> I would like to refer to image.gif in help.html under staticpages directory.
> Most of the images I want to refer in the HTML files resides in the same
> directory.
>
> I used mount(new IndexedParamUrlCodingStrategy("/static",
> StaticPage.class)); to mount in Application class and  static/help.html HELP
> to access the help.html page. In StaticPage.java, my basePath is
> "/staticpages". So I append my resource, in this case "help.html" to my base
> path to get to it.
>
> In help.html, if I use
> {img src="image.gif" /}
> {img src="staticpages/image.gif" /}
>
> image does not show up, but if I use
>
> {img src="../staticpages/svs_logo_header.gif" /}
> image shows up. It doesn't make sense that I have to go up and down levels
> in the directory just to get to the image in the same directory. I am really
> confused :( Please help.
>
> Thanks.
>
>
>
>
>
>
>
>
> igor.vaynberg wrote:
>>
>> what happens when you paste the url of the image directly into the
>> browser's address bar?
>>
>> this wouldnt be wicket finding or rendering the images, they would be
>> served directly by the servlet container.
>>
>> -igor
>>
>> On Tue, Mar 3, 2009 at 7:46 AM, Vika <Vi...@nasa.gov> wrote:
>>>
>>> I am having the same problem!
>>>
>>>
>>> matrixguy wrote:
>>>>
>>>> Hi,
>>>>
>>>> The following code worked very nicely with the text in the HTML file,
>>>> but
>>>> it's not working with the embedded images in the HTML file. I have
>>>> verified that wicket can find the images (so it's not the path issue for
>>>> the images). It's as if wicket can find the images but not able to
>>>> render
>>>> them. :( Any ideas?
>>>>
>>>> Thanks.
>>>>
>>>>
>>>>
>>>>
>>>> igor.vaynberg wrote:
>>>>>
>>>>> all you have to do is this:
>>>>>
>>>>> mount(new indexedparamcodingstrategy("/static", StaticPage.class));
>>>>>
>>>>> class staticpage extends MyBasePageWithDecoratingMarkup {
>>>>>   private final String resource;
>>>>>   public staticpage(PageParameters params) {
>>>>>     resource=params.get("0");
>>>>>     add(new Label("content", new PropertyModel(this,
>>>>> "content")).setEscapeModelStrings(false));
>>>>>   }
>>>>>
>>>>>   public String getContent() {
>>>>>      // load the resource content however you want
>>>>>      InputStream is=new FileInputStream(basePath+"/"+resource);
>>>>>      try {
>>>>>         return Streams.readIntoString(is);
>>>>>      } finally { is.close(); }
>>>>>   }
>>>>> }
>>>>>
>>>>> static.page.html: [wicket:extend][wicket:container
>>>>> wicket:id="content"]content will be
>>>>> here[/wicket:container][/wicket:extend]
>>>>>
>>>>> then if you go to /static/myfile.html the contents of myfile.html will
>>>>> be shown within your decorated page
>>>>>
>>>>> -igor
>>>>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p22317120.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 give static pages consistant look with wicket - partial repeat

Posted by matrixguy <pe...@hotmail.com>.
Hi Igor,

I am having problems with loading images. I have the following directory
structure:

-web
--staticpages
----help.html
----image.gif
--scripts
and so on...

I would like to refer to image.gif in help.html under staticpages directory.
Most of the images I want to refer in the HTML files resides in the same
directory.

I used mount(new IndexedParamUrlCodingStrategy("/static",
StaticPage.class)); to mount in Application class and  static/help.html HELP 
to access the help.html page. In StaticPage.java, my basePath is
"/staticpages". So I append my resource, in this case "help.html" to my base
path to get to it.

In help.html, if I use 
image.gif 
staticpages/image.gif 

image does not show up, but if I use

../staticpages/svs_logo_header.gif 
image shows up. It doesn't make sense that I have to go up and down levels
in the directory just to get to the image in the same directory. I am really
confused :( Please help.

Thanks.








igor.vaynberg wrote:
> 
> what happens when you paste the url of the image directly into the
> browser's address bar?
> 
> this wouldnt be wicket finding or rendering the images, they would be
> served directly by the servlet container.
> 
> -igor
> 
> On Tue, Mar 3, 2009 at 7:46 AM, Vika <Vi...@nasa.gov> wrote:
>>
>> I am having the same problem!
>>
>>
>> matrixguy wrote:
>>>
>>> Hi,
>>>
>>> The following code worked very nicely with the text in the HTML file,
>>> but
>>> it's not working with the embedded images in the HTML file. I have
>>> verified that wicket can find the images (so it's not the path issue for
>>> the images). It's as if wicket can find the images but not able to
>>> render
>>> them. :( Any ideas?
>>>
>>> Thanks.
>>>
>>>
>>>
>>>
>>> igor.vaynberg wrote:
>>>>
>>>> all you have to do is this:
>>>>
>>>> mount(new indexedparamcodingstrategy("/static", StaticPage.class));
>>>>
>>>> class staticpage extends MyBasePageWithDecoratingMarkup {
>>>>   private final String resource;
>>>>   public staticpage(PageParameters params) {
>>>>     resource=params.get("0");
>>>>     add(new Label("content", new PropertyModel(this,
>>>> "content")).setEscapeModelStrings(false));
>>>>   }
>>>>
>>>>   public String getContent() {
>>>>      // load the resource content however you want
>>>>      InputStream is=new FileInputStream(basePath+"/"+resource);
>>>>      try {
>>>>         return Streams.readIntoString(is);
>>>>      } finally { is.close(); }
>>>>   }
>>>> }
>>>>
>>>> static.page.html: [wicket:extend][wicket:container
>>>> wicket:id="content"]content will be
>>>> here[/wicket:container][/wicket:extend]
>>>>
>>>> then if you go to /static/myfile.html the contents of myfile.html will
>>>> be shown within your decorated page
>>>>
>>>> -igor
>>>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p22317120.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 give static pages consistant look with wicket - partial repeat

Posted by Igor Vaynberg <ig...@gmail.com>.
what happens when you paste the url of the image directly into the
browser's address bar?

this wouldnt be wicket finding or rendering the images, they would be
served directly by the servlet container.

-igor

On Tue, Mar 3, 2009 at 7:46 AM, Vika <Vi...@nasa.gov> wrote:
>
> I am having the same problem!
>
>
> matrixguy wrote:
>>
>> Hi,
>>
>> The following code worked very nicely with the text in the HTML file, but
>> it's not working with the embedded images in the HTML file. I have
>> verified that wicket can find the images (so it's not the path issue for
>> the images). It's as if wicket can find the images but not able to render
>> them. :( Any ideas?
>>
>> Thanks.
>>
>>
>>
>>
>> igor.vaynberg wrote:
>>>
>>> all you have to do is this:
>>>
>>> mount(new indexedparamcodingstrategy("/static", StaticPage.class));
>>>
>>> class staticpage extends MyBasePageWithDecoratingMarkup {
>>>   private final String resource;
>>>   public staticpage(PageParameters params) {
>>>     resource=params.get("0");
>>>     add(new Label("content", new PropertyModel(this,
>>> "content")).setEscapeModelStrings(false));
>>>   }
>>>
>>>   public String getContent() {
>>>      // load the resource content however you want
>>>      InputStream is=new FileInputStream(basePath+"/"+resource);
>>>      try {
>>>         return Streams.readIntoString(is);
>>>      } finally { is.close(); }
>>>   }
>>> }
>>>
>>> static.page.html: [wicket:extend][wicket:container
>>> wicket:id="content"]content will be
>>> here[/wicket:container][/wicket:extend]
>>>
>>> then if you go to /static/myfile.html the contents of myfile.html will
>>> be shown within your decorated page
>>>
>>> -igor
>>>
>>> On Wed, Feb 11, 2009 at 8:45 AM, Vika <Vi...@nasa.gov> wrote:
>>>>
>>>> I am looking at wicket trying to decide if i would want to use it for my
>>>> project.
>>>> Currently I am struggling trying to give static and dynamic pages
>>>> consistent
>>>> look with wicket without using sitemesh.  I was able to get wicket
>>>> application to direct all static page requests to my wicket StaticPage
>>>> that
>>>> would read the content of a file and add it to the page as
>>>> MultiLineLabel.
>>>> However my problem is that i don't want to add whole html file. I need
>>>> to
>>>> extract the content of <title>, <body> and <meta> tags and add these
>>>> separately. Is there anything in api or any examples i should look at ?
>>>>
>>>> Please see the code below.
>>>>
>>>> in Aplication.java  init()
>>>>
>>>> mount(new URIRequestTargetUrlCodingStrategy("/docs")
>>>>        {
>>>>            @Override
>>>>            public IRequestTarget decode(RequestParameters
>>>> requestParameters)
>>>>            {
>>>>                String path = "/app/" + getURI(requestParameters);
>>>>                return new PageRequestTarget(new StaticPage(new
>>>> WebExternalResourceRequestTarget(path)));
>>>>            }
>>>>        });
>>>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
>>>> in StaicPage.java
>>>> public class StaticPage extends BasePage implements AuthenticatedWebPage
>>>> {
>>>>        public StaticPage(WebExternalResourceRequestTarget
>>>> staticResource)
>>>>        {
>>>>                String staticResourceContent = "";
>>>>                try {
>>>>                        staticResourceContent =
>>>>
>>>> convertStreamToString(staticResource.getResourceStream().getInputStream());
>>>>                } catch (ResourceStreamNotFoundException e)
>>>>                {
>>>>                        // TODO Auto-generated catch block
>>>>                        e.printStackTrace();
>>>>                }
>>>>                add(new MultiLineLabel("staticContent",
>>>> staticResourceContent));
>>>>        }
>>>> }
>>>> ---------------------------------------------------------------------------------------------------------------------------
>>>> Here is what i get in the browser when click on static link:
>>>>
>>>> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>>> "http://www.w3.org/TR/html4/loose.dtd">
>>>> <html>
>>>> <head>
>>>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>>>> <title>Insert title here</title>
>>>> </head>
>>>> <body>
>>>> this is a test
>>>> </body>
>>>> </html>
>>>> This is in the footer
>>>> --------------------------------------------------------------------------------------------------
>>>>
>>>> Another variation of StaticPage.java i tried was
>>>> public class StaticPage extends BasePage implements AuthenticatedWebPage
>>>> {
>>>>        public StaticPage(WebExternalResourceRequestTarget
>>>> staticResource)
>>>>        {
>>>>                MarkupResourceStream markupStream =
>>>>                        new
>>>> MarkupResourceStream(staticResource.getResourceStream());
>>>>
>>>>
>>>>                MarkupParser parser = new MarkupParser(markupStream);
>>>>
>>>>                Markup markup = parser.parse();
>>>>
>>>> However I got stuck at this point since i still don't see a way of
>>>> getting
>>>> individual html tags from Markup
>>>>
>>>>
>>>> thank you in advance,
>>>>
>>>> Vicky
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p21958254.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
>>>
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p22311189.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 give static pages consistant look with wicket - partial repeat

Posted by Vika <Vi...@nasa.gov>.
I am having the same problem!


matrixguy wrote:
> 
> Hi,
> 
> The following code worked very nicely with the text in the HTML file, but
> it's not working with the embedded images in the HTML file. I have
> verified that wicket can find the images (so it's not the path issue for
> the images). It's as if wicket can find the images but not able to render
> them. :( Any ideas?
> 
> Thanks.
> 
> 
> 
> 
> igor.vaynberg wrote:
>> 
>> all you have to do is this:
>> 
>> mount(new indexedparamcodingstrategy("/static", StaticPage.class));
>> 
>> class staticpage extends MyBasePageWithDecoratingMarkup {
>>   private final String resource;
>>   public staticpage(PageParameters params) {
>>     resource=params.get("0");
>>     add(new Label("content", new PropertyModel(this,
>> "content")).setEscapeModelStrings(false));
>>   }
>> 
>>   public String getContent() {
>>      // load the resource content however you want
>>      InputStream is=new FileInputStream(basePath+"/"+resource);
>>      try {
>>         return Streams.readIntoString(is);
>>      } finally { is.close(); }
>>   }
>> }
>> 
>> static.page.html: [wicket:extend][wicket:container
>> wicket:id="content"]content will be
>> here[/wicket:container][/wicket:extend]
>> 
>> then if you go to /static/myfile.html the contents of myfile.html will
>> be shown within your decorated page
>> 
>> -igor
>> 
>> On Wed, Feb 11, 2009 at 8:45 AM, Vika <Vi...@nasa.gov> wrote:
>>>
>>> I am looking at wicket trying to decide if i would want to use it for my
>>> project.
>>> Currently I am struggling trying to give static and dynamic pages
>>> consistent
>>> look with wicket without using sitemesh.  I was able to get wicket
>>> application to direct all static page requests to my wicket StaticPage
>>> that
>>> would read the content of a file and add it to the page as
>>> MultiLineLabel.
>>> However my problem is that i don't want to add whole html file. I need
>>> to
>>> extract the content of <title>, <body> and <meta> tags and add these
>>> separately. Is there anything in api or any examples i should look at ?
>>>
>>> Please see the code below.
>>>
>>> in Aplication.java  init()
>>>
>>> mount(new URIRequestTargetUrlCodingStrategy("/docs")
>>>        {
>>>            @Override
>>>            public IRequestTarget decode(RequestParameters
>>> requestParameters)
>>>            {
>>>                String path = "/app/" + getURI(requestParameters);
>>>                return new PageRequestTarget(new StaticPage(new
>>> WebExternalResourceRequestTarget(path)));
>>>            }
>>>        });
>>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
>>> in StaicPage.java
>>> public class StaticPage extends BasePage implements AuthenticatedWebPage
>>> {
>>>        public StaticPage(WebExternalResourceRequestTarget
>>> staticResource)
>>>        {
>>>                String staticResourceContent = "";
>>>                try {
>>>                        staticResourceContent =
>>>
>>> convertStreamToString(staticResource.getResourceStream().getInputStream());
>>>                } catch (ResourceStreamNotFoundException e)
>>>                {
>>>                        // TODO Auto-generated catch block
>>>                        e.printStackTrace();
>>>                }
>>>                add(new MultiLineLabel("staticContent",
>>> staticResourceContent));
>>>        }
>>> }
>>> ---------------------------------------------------------------------------------------------------------------------------
>>> Here is what i get in the browser when click on static link:
>>>
>>> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>> "http://www.w3.org/TR/html4/loose.dtd">
>>> <html>
>>> <head>
>>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>>> <title>Insert title here</title>
>>> </head>
>>> <body>
>>> this is a test
>>> </body>
>>> </html>
>>> This is in the footer
>>> --------------------------------------------------------------------------------------------------
>>>
>>> Another variation of StaticPage.java i tried was
>>> public class StaticPage extends BasePage implements AuthenticatedWebPage
>>> {
>>>        public StaticPage(WebExternalResourceRequestTarget
>>> staticResource)
>>>        {
>>>                MarkupResourceStream markupStream =
>>>                        new
>>> MarkupResourceStream(staticResource.getResourceStream());
>>>
>>>
>>>                MarkupParser parser = new MarkupParser(markupStream);
>>>
>>>                Markup markup = parser.parse();
>>>
>>> However I got stuck at this point since i still don't see a way of
>>> getting
>>> individual html tags from Markup
>>>
>>>
>>> thank you in advance,
>>>
>>> Vicky
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p21958254.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
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p22311189.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 give static pages consistant look with wicket - partial repeat

Posted by matrixguy <pe...@hotmail.com>.
Hi,

The following code worked very nicely with the text in the HTML file, but
it's not working with the embedded images in the HTML file. I have verified
that wicket can find the images (so it's not the path issue for the images).
It's as if wicket can find the images but not able to render them. :( Any
ideas?

Thanks.




igor.vaynberg wrote:
> 
> all you have to do is this:
> 
> mount(new indexedparamcodingstrategy("/static", StaticPage.class));
> 
> class staticpage extends MyBasePageWithDecoratingMarkup {
>   private final String resource;
>   public staticpage(PageParameters params) {
>     resource=params.get("0");
>     add(new Label("content", new PropertyModel(this,
> "content")).setEscapeModelStrings(false));
>   }
> 
>   public String getContent() {
>      // load the resource content however you want
>      InputStream is=new FileInputStream(basePath+"/"+resource);
>      try {
>         return Streams.readIntoString(is);
>      } finally { is.close(); }
>   }
> }
> 
> static.page.html: [wicket:extend][wicket:container
> wicket:id="content"]content will be
> here[/wicket:container][/wicket:extend]
> 
> then if you go to /static/myfile.html the contents of myfile.html will
> be shown within your decorated page
> 
> -igor
> 
> On Wed, Feb 11, 2009 at 8:45 AM, Vika <Vi...@nasa.gov> wrote:
>>
>> I am looking at wicket trying to decide if i would want to use it for my
>> project.
>> Currently I am struggling trying to give static and dynamic pages
>> consistent
>> look with wicket without using sitemesh.  I was able to get wicket
>> application to direct all static page requests to my wicket StaticPage
>> that
>> would read the content of a file and add it to the page as
>> MultiLineLabel.
>> However my problem is that i don't want to add whole html file. I need to
>> extract the content of <title>, <body> and <meta> tags and add these
>> separately. Is there anything in api or any examples i should look at ?
>>
>> Please see the code below.
>>
>> in Aplication.java  init()
>>
>> mount(new URIRequestTargetUrlCodingStrategy("/docs")
>>        {
>>            @Override
>>            public IRequestTarget decode(RequestParameters
>> requestParameters)
>>            {
>>                String path = "/app/" + getURI(requestParameters);
>>                return new PageRequestTarget(new StaticPage(new
>> WebExternalResourceRequestTarget(path)));
>>            }
>>        });
>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
>> in StaicPage.java
>> public class StaticPage extends BasePage implements AuthenticatedWebPage
>> {
>>        public StaticPage(WebExternalResourceRequestTarget staticResource)
>>        {
>>                String staticResourceContent = "";
>>                try {
>>                        staticResourceContent =
>>
>> convertStreamToString(staticResource.getResourceStream().getInputStream());
>>                } catch (ResourceStreamNotFoundException e)
>>                {
>>                        // TODO Auto-generated catch block
>>                        e.printStackTrace();
>>                }
>>                add(new MultiLineLabel("staticContent",
>> staticResourceContent));
>>        }
>> }
>> ---------------------------------------------------------------------------------------------------------------------------
>> Here is what i get in the browser when click on static link:
>>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>> "http://www.w3.org/TR/html4/loose.dtd">
>> <html>
>> <head>
>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>> <title>Insert title here</title>
>> </head>
>> <body>
>> this is a test
>> </body>
>> </html>
>> This is in the footer
>> --------------------------------------------------------------------------------------------------
>>
>> Another variation of StaticPage.java i tried was
>> public class StaticPage extends BasePage implements AuthenticatedWebPage
>> {
>>        public StaticPage(WebExternalResourceRequestTarget staticResource)
>>        {
>>                MarkupResourceStream markupStream =
>>                        new
>> MarkupResourceStream(staticResource.getResourceStream());
>>
>>
>>                MarkupParser parser = new MarkupParser(markupStream);
>>
>>                Markup markup = parser.parse();
>>
>> However I got stuck at this point since i still don't see a way of
>> getting
>> individual html tags from Markup
>>
>>
>> thank you in advance,
>>
>> Vicky
>>
>> --
>> View this message in context:
>> http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p21958254.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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p22171187.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 give static pages consistant look with wicket - partial repeat

Posted by Igor Vaynberg <ig...@gmail.com>.
all you have to do is this:

mount(new indexedparamcodingstrategy("/static", StaticPage.class));

class staticpage extends MyBasePageWithDecoratingMarkup {
  private final String resource;
  public staticpage(PageParameters params) {
    resource=params.get("0");
    add(new Label("content", new PropertyModel(this,
"content")).setEscapeModelStrings(false));
  }

  public String getContent() {
     // load the resource content however you want
     InputStream is=new FileInputStream(basePath+"/"+resource);
     try {
        return Streams.readIntoString(is);
     } finally { is.close(); }
  }
}

static.page.html: [wicket:extend][wicket:container
wicket:id="content"]content will be
here[/wicket:container][/wicket:extend]

then if you go to /static/myfile.html the contents of myfile.html will
be shown within your decorated page

-igor

On Wed, Feb 11, 2009 at 8:45 AM, Vika <Vi...@nasa.gov> wrote:
>
> I am looking at wicket trying to decide if i would want to use it for my
> project.
> Currently I am struggling trying to give static and dynamic pages consistent
> look with wicket without using sitemesh.  I was able to get wicket
> application to direct all static page requests to my wicket StaticPage that
> would read the content of a file and add it to the page as MultiLineLabel.
> However my problem is that i don't want to add whole html file. I need to
> extract the content of <title>, <body> and <meta> tags and add these
> separately. Is there anything in api or any examples i should look at ?
>
> Please see the code below.
>
> in Aplication.java  init()
>
> mount(new URIRequestTargetUrlCodingStrategy("/docs")
>        {
>            @Override
>            public IRequestTarget decode(RequestParameters
> requestParameters)
>            {
>                String path = "/app/" + getURI(requestParameters);
>                return new PageRequestTarget(new StaticPage(new
> WebExternalResourceRequestTarget(path)));
>            }
>        });
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
> in StaicPage.java
> public class StaticPage extends BasePage implements AuthenticatedWebPage
> {
>        public StaticPage(WebExternalResourceRequestTarget staticResource)
>        {
>                String staticResourceContent = "";
>                try {
>                        staticResourceContent =
>
> convertStreamToString(staticResource.getResourceStream().getInputStream());
>                } catch (ResourceStreamNotFoundException e)
>                {
>                        // TODO Auto-generated catch block
>                        e.printStackTrace();
>                }
>                add(new MultiLineLabel("staticContent",
> staticResourceContent));
>        }
> }
> ---------------------------------------------------------------------------------------------------------------------------
> Here is what i get in the browser when click on static link:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
> <title>Insert title here</title>
> </head>
> <body>
> this is a test
> </body>
> </html>
> This is in the footer
> --------------------------------------------------------------------------------------------------
>
> Another variation of StaticPage.java i tried was
> public class StaticPage extends BasePage implements AuthenticatedWebPage
> {
>        public StaticPage(WebExternalResourceRequestTarget staticResource)
>        {
>                MarkupResourceStream markupStream =
>                        new MarkupResourceStream(staticResource.getResourceStream());
>
>
>                MarkupParser parser = new MarkupParser(markupStream);
>
>                Markup markup = parser.parse();
>
> However I got stuck at this point since i still don't see a way of getting
> individual html tags from Markup
>
>
> thank you in advance,
>
> Vicky
>
> --
> View this message in context: http://www.nabble.com/how-to-give-static-pages-consistant-look-with-wicket---partial-repeat-tp21958254p21958254.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