Re: Using Include and placing pages under WEB-INF

2007-09-09 Thread Jason Mihalick

Ah, that's true, wicket takes care of resolving the URL and including the
content.  

I see your point.  My concern was for containers that don't explode the WAR
when deployed, but I think yours should work for that too, and it avoids the
subclass.

Thanks!



Jason Mihalick wrote:
 
 Thanks, yes, my solution was close to this, but I opted instead to
 subclass the Include class.  I think the solution that you propose below
 may cause wicket to create an absolute URL to the HTML files under the
 WEB-INF dir which will be inaccessible by the browser. /quote
 
 No. The URL is never sent to the browser. In fact, logically your code is
 exactly the same as mine.
 

-- 
View this message in context: 
http://www.nabble.com/Using-Include-and-placing-pages-under-WEB-INF-tf4403861.html#a12576277
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using Include and placing pages under WEB-INF

2007-09-08 Thread Kent Tong


Jason Mihalick wrote:
 
 However, if I try to move my pages under WEB-INF, wicket has a problem
 loading resources that are bound via the
 org.apache.wicket.markup.html.include.Include class.  In my case, I have
 several static pages that I want to load dynamically which are located in
 my 'help/' directory (see above). 
 

Try:
File context = new
File(((WebApplication)getApplication()).getServletContext().getRealPath(/));
File file = new File(context, WEB-INF/help/Topic1.html);
Include i = new Include(i, file.toURL().toString());

-- 
View this message in context: 
http://www.nabble.com/Using-Include-and-placing-pages-under-WEB-INF-tf4403861.html#a12569783
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using Include and placing pages under WEB-INF

2007-09-08 Thread Jason Mihalick

Thank you for the suggestion.  This looks like it ought to work fine for
exploded WARs, but it seems like it would be a problem when then app is
deployed in a WAR.  Is there any way to do this that will work when the app
is deployed in a WAR archive?  Or is there perhaps another wicket component
that I should be using that won't require me to create a companion Java
class for each help snippet?

Thanks.

--
Jason


Kent Tong wrote:
 
 
 Jason Mihalick wrote:
 
 However, if I try to move my pages under WEB-INF, wicket has a problem
 loading resources that are bound via the
 org.apache.wicket.markup.html.include.Include class.  In my case, I have
 several static pages that I want to load dynamically which are located in
 my 'help/' directory (see above). 
 
 
 Try:
   File context = new
 File(((WebApplication)getApplication()).getServletContext().getRealPath(/));
   File file = new File(context, WEB-INF/help/Topic1.html);
   Include i = new Include(i, file.toURL().toString());
 
 

-- 
View this message in context: 
http://www.nabble.com/Using-Include-and-placing-pages-under-WEB-INF-tf4403861.html#a12574436
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using Include and placing pages under WEB-INF

2007-09-08 Thread Kent Tong



Jason Mihalick wrote:
 
 Thank you for the suggestion.  This looks like it ought to work fine for
 exploded WARs, but it seems like it would be a problem when then app is
 deployed in a WAR.  Is there any way to do this that will work when the
 app is deployed in a WAR archive?  Or is there perhaps another wicket
 component that I should be using that won't require me to create a
 companion Java class for each help snippet?
 

Try:

URL url = ((WebApplication)
getApplication()).getServletContext().getResource(/WEB-INF/help/topic1.html);
add(new Include(i, url.toString()));

-- 
View this message in context: 
http://www.nabble.com/Using-Include-and-placing-pages-under-WEB-INF-tf4403861.html#a12576037
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using Include and placing pages under WEB-INF

2007-09-08 Thread Jason Mihalick

Thanks, yes, my solution was close to this, but I opted instead to subclass
the Include class.  I think the solution that you propose below may cause
wicket to create an absolute URL to the HTML files under the WEB-INF dir
which will be inaccessible by the browser.  Here is my subclass of the
Include class, which is working well for me:

public class ResourceInclude extends Include {
  private static final long serialVersionUID = 1L;
  
  private final static Logger log = LoggerFactory.getLogger(
ResourceInclude.class );

  /**
   * Constructs a new ResourceInclude object.
   * @param id The identifier of the wicket markup that this ResourceInclude
is bound to.
   * @param resourcePath The resource location of the content to load.  This
should be
   * a resource path that is reachable from the ServletContext via a call to 
   * ServletContext.getResource(String).
   */
  public ResourceInclude( String id, String resourcePath ) {
super( id, resourcePath );
  }
  
  /**
   * Override of the importAsString method to load the content from the
resource path that was
   * provided during consturction.
   * @see org.apache.wicket.markup.html.include.Include#importAsString()
   */
  @Override
  protected String importAsString() {
String url = this.getModelObjectAsString();

if ( !isAbsolute( url ) ) {
  try {
UrlResourceStream resourceStream = new UrlResourceStream( 
   
((WebApplication)this.getApplication()).getServletContext().getResource( url
) );

return resourceStream.asString();
  
  } catch ( Exception ex ) {
log.error( Error loading help file at resource location:  +
this.getModelObjectAsString(), ex );
return super.importAsString();
  }
} else {
  return super.importAsString();
}
  }
}


Kent Tong wrote:
 
 
 
 Jason Mihalick wrote:
 
 Thank you for the suggestion.  This looks like it ought to work fine for
 exploded WARs, but it seems like it would be a problem when then app is
 deployed in a WAR.  Is there any way to do this that will work when the
 app is deployed in a WAR archive?  Or is there perhaps another wicket
 component that I should be using that won't require me to create a
 companion Java class for each help snippet?
 
 
 Try:
 
   URL url = ((WebApplication)
 getApplication()).getServletContext().getResource(/WEB-INF/help/topic1.html);
   add(new Include(i, url.toString()));
 
 

-- 
View this message in context: 
http://www.nabble.com/Using-Include-and-placing-pages-under-WEB-INF-tf4403861.html#a12576080
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using Include and placing pages under WEB-INF

2007-09-08 Thread Kent Tong


Thanks, yes, my solution was close to this, but I opted instead to subclass
the Include class.  I think the solution that you propose below may cause
wicket to create an absolute URL to the HTML files under the WEB-INF dir
which will be inaccessible by the browser. /quote

No. The URL is never sent to the browser. In fact, logically your code is
exactly the same as mine.
-- 
View this message in context: 
http://www.nabble.com/Using-Include-and-placing-pages-under-WEB-INF-tf4403861.html#a12576120
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Using Include and placing pages under WEB-INF

2007-09-07 Thread Jason Mihalick

Hello,

I have followed the instructions on the wiki for placing HTML pages in an
alternative location
(http://cwiki.apache.org/WICKET/control-where-html-files-are-loaded-from.html). 
The location I chose was at the context root.  I.e., 


webapp/
   +--- WEB-INF/
   +--- css/
   +--- img/
   +--- js/
   +--- help/
   +--- Page1.html
   +--- Page2.html
... etc.

When I locate the pages there and add the appropriate resource folder (using
IResourceSettings.addResourceFolder(String) ), everything works fine in my
wicket application.

However, if I try to move my pages under WEB-INF, wicket has a problem
loading resources that are bound via the
org.apache.wicket.markup.html.include.Include class.  In my case, I have
several static pages that I want to load dynamically which are located in my
'help/' directory (see above).  When the user loads Page1.html, I want to
load HTML from a corresponding help page and place that HTML into a panel. 
When they load Page2.html, I want to load HTML from another help page, etc. 
This is all working great with the wicket Include mechanism ... until I move
the pages under the WEB-INF dir.  When I do that, I get messages like
this...

[ERROR] 09/07/07 12.49.11.011 org.apache.wicket.RequestCycle:1255 - Unable
to read resource as String
org.apache.wicket.WicketRuntimeException: Unable to read resource as String
at
org.apache.wicket.util.resource.AbstractResourceStream.asString(AbstractResourceStream.java:77)
at
org.apache.wicket.markup.html.include.Include.importUrl(Include.java:266)
at
org.apache.wicket.markup.html.include.Include.importAbsoluteUrl(Include.java:248)
at
org.apache.wicket.markup.html.include.Include.importRelativeUrl(Include.java:234)
at
org.apache.wicket.markup.html.include.Include.importAsString(Include.java:158)
at
org.apache.wicket.markup.html.include.Include.onComponentTagBody(Include.java:172)

Is it possible to do what I'm attempting to do?

Thanks in advance!  

(Thanks also to the wicket developers for creating such a great framework!)

--
Jason


-- 
View this message in context: 
http://www.nabble.com/Using-Include-and-placing-pages-under-WEB-INF-tf4403861.html#a12563577
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]