You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jochen Heintz <jo...@gameforge.com> on 2011/04/13 17:04:38 UTC

Absolute Paths in Tapestry 5.2.5

Hi !

I'm using Tapestry 5.2.5 and i use Glassfish behind a apache httpd as a
proxy.

The httpd is doing a ProxyPass / http://localhost:8080/myApp so that i am
able to call my site
from the root.

I'm able to see my site at http://test.local/ instead of
http://test.local/myApp.

That works fine except the Javascript stuff. I see in the sources of the
webpage 
that there is a path to /myApp/0.1-SNAPSHOT/stack/core.js is inserted.

But there is no path beginning with /myApp... because i changed this with
the proxy to the root of the 
domain.

Is it possible to change those relative uris to absolute uris ?

Thanks a lot
Jochen







--
View this message in context: http://tapestry.1045711.n5.nabble.com/Absolute-Paths-in-Tapestry-5-2-5-tp4300824p4300824.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Absolute Paths in Tapestry 5.2.5

Posted by Josh Canfield <jo...@gmail.com>.
Are you deploying multiple apps to glassfish? If not have you
considered deploying your app to the root context?

On Wed, Apr 13, 2011 at 8:04 AM, Jochen Heintz
<jo...@gameforge.com> wrote:
> Hi !
>
> I'm using Tapestry 5.2.5 and i use Glassfish behind a apache httpd as a
> proxy.
>
> The httpd is doing a ProxyPass / http://localhost:8080/myApp so that i am
> able to call my site
> from the root.
>
> I'm able to see my site at http://test.local/ instead of
> http://test.local/myApp.
>
> That works fine except the Javascript stuff. I see in the sources of the
> webpage
> that there is a path to /myApp/0.1-SNAPSHOT/stack/core.js is inserted.
>
> But there is no path beginning with /myApp... because i changed this with
> the proxy to the root of the
> domain.
>
> Is it possible to change those relative uris to absolute uris ?
>
> Thanks a lot
> Jochen
>
>
>
>
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Absolute-Paths-in-Tapestry-5-2-5-tp4300824p4300824.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: Absolute Paths in Tapestry 5.2.5

Posted by Christian Köberl <ta...@gmail.com>.
Just tried that - AJAX works for me as well.

Here's what I did:
1. Create app with archetype

2. Add form with <input t:type="TextField" t:id="text" type="text" 
t:mixins="autocomplete" />

3. In AppModule create a handler class
class AppModule
{
...
     private static class ChangeContextPathnHttpServletRequestWrapper 
extends HttpServletRequestWrapper
     {
         private final String contextPath;

         public 
ChangeContextPathnHttpServletRequestWrapper(HttpServletRequest request, 
String contextPath)
         {
             super(request);
             this.contextPath = contextPath;
         }

         @Override
         public String getContextPath()
         {
             return contextPath;
         }
     }
}

4. in AppModule contribute my handler:
class AppModule
{
...
     public void 
contributeHttpServletRequestHandler(OrderedConfiguration<HttpServletRequestFilter> 
configuration)
     {
         configuration.add("ManipulateContextPath", new 
HttpServletRequestFilter()
         {
             public boolean service(HttpServletRequest request, 
HttpServletResponse response, HttpServletRequestHandler handler)
 
                                                         throws IOException
             {
                 return handler.service(new 
ChangeContextPathnHttpServletRequestWrapper(request, ""), response);
             }
         });
     }
}

5. Run app with context path (e.g. "/demo")

Request http://localhost:8080/demo/

==> AJAX paths are rewritten:

Tapestry.init({
   "activate" : [
     "text"
   ],
   "autocompleter" : [
     {
       "elementId" : "text",
       "config" : {
         "indicator" : "text:loader",
         "paramName" : "t:input"
       },
       "menuId" : "text:menu",
       "url" : "/index.text:autocomplete"
     }
   ]
});

-- 
Chris

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


Re: Absolute Paths in Tapestry 5.2.5

Posted by Jochen Heintz <jo...@gameforge.com>.
The path seems to be working now....

but the problem with the ajax resists....

in my generated site i have a autocompleter and in the sourcecode of the
site i found this

Tapestry.onDOMLoaded(function() {
Tapestry.init({
  "autocompleter" : [
    [
      "nameInput",
      "nameInput:menu",
      "/myApp/game/account/givegift.playerinput.nameinput:autocomplete",  
<------- xxxxxxxxx
      {
        "minChars" : 3,
        "indicator" : "nameInput:loader",
        "paramName" : "t:input"
      }
    ]
  ]
});

I think the autocompleter does not work because of the relative path
here....

Thanks for all replies!
Jochen

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Absolute-Paths-in-Tapestry-5-2-5-tp4300824p4305448.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Absolute Paths in Tapestry 5.2.5

Posted by Jochen Heintz <jo...@gameforge.com>.
Hi Christian,

tank you for this great Tip! I overridden the getContextPath() method and it
gets called....
but after i return "/"  i get a timeout at the browser.
Your tip sounds good and i have to investigate further.

Thanks a lot!
Jochen

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Absolute-Paths-in-Tapestry-5-2-5-tp4300824p4305176.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Absolute Paths in Tapestry 5.2.5

Posted by Christian Köberl <ta...@gmail.com>.
 > Take a look at BaseURLSource.
I think that's not the right place - BaseURLSource is for the URL before 
the context path.

The context path is obtained via 
org.apache.tapestry5.services.Request#getContextPath() which delegates 
to javax.servlet.http.HttpServletRequest#getContextPath().

Bad news: the problem is that you cannot decorate/replace Request and 
HttpServletRequest because these are no services.

What you could do is contribute an HttpServletRequestFilter to 
HttpServletRequestHandler which wraps the HttpServletRequest in a 
HttpServletRequestWrapper changing the getContextPath() method to return 
"/".

-- 
Chris

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


Re: Absolute Paths in Tapestry 5.2.5

Posted by Jochen Heintz <jo...@gameforge.com>.
Hi,

yes you are right....

That is my apache httpd-vhosts.conf


        ServerName myApp
	ProxyPass / http://localhost:8080/myApp/
	ProxyPassReverse / http://localhost:8080/myApp/


Maybe i cannot use this proxypass rule as i wanted.
Or we doing here unusual things ?

Greetings
Jochen

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Absolute-Paths-in-Tapestry-5-2-5-tp4300824p4302551.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Absolute Paths in Tapestry 5.2.5

Posted by Jochen Berger <fo...@googlemail.com>.
Jochen,

Am Donnerstag, den 14.04.2011, 00:29 -0700 schrieb Jochen Heintz:
> Thank you all for your replies !
> 
> > ProxyPass /myApp http://localhost:8080/myApp
> > ProxyPassReverse /myApp http://localhost:8080/myApp
> 
> The above rules are working but i want to hide the appname and have a rule
> like this
> 
> ProxyPass / http://localhost:8080/myApp
> ProxyPassReverse / http://localhost:8080/myApp

I guess that would have to read "http://localhost:8080/myApp/" including
the trailing slash, wouldn't it?




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


Re: Absolute Paths in Tapestry 5.2.5

Posted by Jochen Heintz <jo...@gameforge.com>.
Thank you all for your replies !

> ProxyPass /myApp http://localhost:8080/myApp
> ProxyPassReverse /myApp http://localhost:8080/myApp

The above rules are working but i want to hide the appname and have a rule
like this

ProxyPass / http://localhost:8080/myApp
ProxyPassReverse / http://localhost:8080/myApp

And thats where the AJAX/Javascript problems start. I think that is because
of the relative path in 
the generated source of the site.
In the source there is a path to core.js -->
/myApp/0.1-SNAPSHOT/stack/core.js

But after the Proxy there is not /myApp anymore

I think i have to change the path of /myApp/0.1-SNAPSHOT/stack/core.js to
/0.1-SNAPSHOT/stack/core.js
or something.

Please correct me if i am wrong.

Thank you all!
Jochen





--
View this message in context: http://tapestry.1045711.n5.nabble.com/Absolute-Paths-in-Tapestry-5-2-5-tp4300824p4302361.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Absolute Paths in Tapestry 5.2.5

Posted by Jochen Berger <fo...@googlemail.com>.
Hi,

Am Mittwoch, den 13.04.2011, 13:08 -0400 schrieb Rich M:
> ProxyPass /myApp http://localhost:8080/myApp
> ProxyPassReverse /myApp http://localhost:8080/myApp

Something like that works for our company too. The ProxyPassReverse
directive seems to be what's missing in your configuration.

Jochen


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


Re: Absolute Paths in Tapestry 5.2.5

Posted by Rich M <ri...@moremagic.com>.
We faced problems with the root and app contexts using HTTPD/Apache in 
front of a Servlet Container as well at my company. Our solution was as 
follows, all in HTTPD. I thought I'd post this in case you find it 
useful. You will probably be interested in the lines from ssl.conf (if 
you don't use HTTPS then put in the httpd.conf). If you run more than 
just the myApp on the server, you'd need a RewriteCond(s) to exempt your 
other apps/pages from the rewrite:

httpd.conf (forces HTTPS and maps to the servlet port on requests to the 
app context):

RewriteEngine On
RewriteCond %{HTTPS} "off"
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

ProxyRequests Off

<Proxy */myApp>
     Order deny,allow
     Allow from all
</Proxy>

ProxyPass /myApp http://localhost:8080/myApp
ProxyPassReverse /myApp http://localhost:8080/myApp

ssl.conf (maps requests not to the app, such as root, to the app context):

RewriteEngine On
RewriteRule !^/myApp https://%{HTTP_HOST}/myApp%{REQUEST_URI}


On 04/13/2011 12:04 PM, Jochen Heintz wrote:
> Hi,
>
> i am tried this in AppModule :
>
>   public static void contributeAlias(Configuration configuration)
>      {
>          BaseURLSource source = new BaseURLSource()
>          {
>              public String getBaseURL(boolean secure)
>              {
>                  return "http://....";
>              }
>          };
>          configuration.add(AliasContribution.create(BaseURLSource.class,
> source));
>      }
>
> but the method getBaseURL gets never called. Did i missed something.
>
> Thanks
> Jochen
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Absolute-Paths-in-Tapestry-5-2-5-tp4300824p4300975.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


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


Re: Absolute Paths in Tapestry 5.2.5

Posted by Jochen Heintz <jo...@gameforge.com>.
Hi,

i am tried this in AppModule :

 public static void contributeAlias(Configuration configuration)
    {
        BaseURLSource source = new BaseURLSource()
        {
            public String getBaseURL(boolean secure)
            {
                return "http://....";
            }
        };
        configuration.add(AliasContribution.create(BaseURLSource.class,
source));
    }

but the method getBaseURL gets never called. Did i missed something.

Thanks
Jochen

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Absolute-Paths-in-Tapestry-5-2-5-tp4300824p4300975.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Absolute Paths in Tapestry 5.2.5

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 13 Apr 2011 12:04:38 -0300, Jochen Heintz  
<jo...@gameforge.com> wrote:

> Hi !

Hi!

> Is it possible to change those relative uris to absolute uris ?

Take a look at BaseURLSource.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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