You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shale.apache.org by Brad Smith <bg...@bendcable.com> on 2007/03/24 15:35:58 UTC

URLs and backing beans

I have an application which needs to handle urls that have the following
patterns:

http://localhost:8080/myapp/projects/office1

http://localhost:8080/myapp/projects/office2

http://localhost:8080/myapp/projects/office2/subofficeA

Conceptually I would like the request to be routed to a single backing
bean called Projects that would use the URL content after ../projects/..
to determine what the response should be.

Are there features in Shale which would make this possible? Is this
where the Application Manager would come into play?



Thank you,

Brad



Re: URLs and backing beans

Posted by Brad Smith <bg...@bendcable.com>.
Thank you Rahul.  Yes the RESTful-ness is intentional. I will look these
references over.

Brad


On Sat, 2007-03-24 at 12:12 -0400, Rahul Akolkar wrote:
> >
> <snip/>
> 
> The RESTful-ness of the URLs (if that was intentional) makes it seem
> like Shale Remoting [1] could be helpful here. In which case, you'd
> need to define a Processor [2] to meet your requirements. The remoting
> module Javadocs are here [3], see package description for the
> org.apache.shale.remoting package for implementation details and
> how-to.
> 
> -Rahul
> 
> (long, possibly fragmented URLs, pointing to latest release docs)
> 
> [1] http://shale.apache.org/1.0.4/shale-remoting/
> [2] http://shale.apache.org/1.0.4/shale-remoting/apidocs/org/apache/shale/remoting/Processor.html
> [3] http://shale.apache.org/1.0.4/shale-remoting/apidocs/


Re: URLs and backing beans

Posted by Rahul Akolkar <ra...@gmail.com>.
On 3/24/07, Brad Smith <bg...@bendcable.com> wrote:
> I have an application which needs to handle urls that have the following
> patterns:
>
> http://localhost:8080/myapp/projects/office1
>
> http://localhost:8080/myapp/projects/office2
>
> http://localhost:8080/myapp/projects/office2/subofficeA
>
> Conceptually I would like the request to be routed to a single backing
> bean called Projects that would use the URL content after ../projects/..
> to determine what the response should be.
>
> Are there features in Shale which would make this possible? Is this
> where the Application Manager would come into play?
>
<snip/>

The RESTful-ness of the URLs (if that was intentional) makes it seem
like Shale Remoting [1] could be helpful here. In which case, you'd
need to define a Processor [2] to meet your requirements. The remoting
module Javadocs are here [3], see package description for the
org.apache.shale.remoting package for implementation details and
how-to.

-Rahul

(long, possibly fragmented URLs, pointing to latest release docs)

[1] http://shale.apache.org/1.0.4/shale-remoting/
[2] http://shale.apache.org/1.0.4/shale-remoting/apidocs/org/apache/shale/remoting/Processor.html
[3] http://shale.apache.org/1.0.4/shale-remoting/apidocs/


>
>
> Thank you,
>
> Brad
>
>
>

SV: SV: URLs and backing beans

Posted by Hermod Opstvedt <he...@opstvedt.com>.
Hi

In which case I guess Rahul's answer was more useful.

Hermod


-----Opprinnelig melding-----
Fra: Brad Smith [mailto:bgsmith@bendcable.com] 
Sendt: 24. mars 2007 17:22
Til: user@shale.apache.org
Emne: Re: SV: URLs and backing beans

Thank you for the reply Hermod.

I should have added that in response to a url such as those in the
original post, the application would return a web page with a list of
projects that are active at each office.  The goal is to have a
bookmarkable URL without creating separate view controllers for each
office (on the order of 1000).

Brad


On Sat, 2007-03-24 at 16:43 +0100, Hermod Opstvedt wrote:
> Hi
> 
> I'm not shure what you are looking for her but his is my understanding of
> it.
> 
> Why would you want a backing bean for this? This is more the
responsibility
> of an ApplicationController. What I would do is to subclass the Shale
> Aplication controller and add the logic you want there. You can use the
> filter mappings to control what gets routed to you
> 
> Backing beans (I take it you mean ViewControllers) are mapped against
views
> i.e page2.jsf, page2.jsf and so on.
> 
> Hermod
> 
> -----Opprinnelig melding-----
> Fra: Brad Smith [mailto:bgsmith@bendcable.com] 
> Sendt: 24. mars 2007 15:36
> Til: user@shale.apache.org
> Emne: URLs and backing beans
> 
> I have an application which needs to handle urls that have the following
> patterns:
> 
> http://localhost:8080/myapp/projects/office1
> 
> http://localhost:8080/myapp/projects/office2
> 
> http://localhost:8080/myapp/projects/office2/subofficeA
> 
> Conceptually I would like the request to be routed to a single backing
> bean called Projects that would use the URL content after ../projects/..
> to determine what the response should be.
> 
> Are there features in Shale which would make this possible? Is this
> where the Application Manager would come into play?
> 
> 
> 
> Thank you,
> 
> Brad
> 
> 


Re: SV: URLs and backing beans

Posted by Brad Smith <bg...@bendcable.com>.
Thank you for the reply Hermod.

I should have added that in response to a url such as those in the
original post, the application would return a web page with a list of
projects that are active at each office.  The goal is to have a
bookmarkable URL without creating separate view controllers for each
office (on the order of 1000).

Brad


On Sat, 2007-03-24 at 16:43 +0100, Hermod Opstvedt wrote:
> Hi
> 
> I'm not shure what you are looking for her but his is my understanding of
> it.
> 
> Why would you want a backing bean for this? This is more the responsibility
> of an ApplicationController. What I would do is to subclass the Shale
> Aplication controller and add the logic you want there. You can use the
> filter mappings to control what gets routed to you
> 
> Backing beans (I take it you mean ViewControllers) are mapped against views
> i.e page2.jsf, page2.jsf and so on.
> 
> Hermod
> 
> -----Opprinnelig melding-----
> Fra: Brad Smith [mailto:bgsmith@bendcable.com] 
> Sendt: 24. mars 2007 15:36
> Til: user@shale.apache.org
> Emne: URLs and backing beans
> 
> I have an application which needs to handle urls that have the following
> patterns:
> 
> http://localhost:8080/myapp/projects/office1
> 
> http://localhost:8080/myapp/projects/office2
> 
> http://localhost:8080/myapp/projects/office2/subofficeA
> 
> Conceptually I would like the request to be routed to a single backing
> bean called Projects that would use the URL content after ../projects/..
> to determine what the response should be.
> 
> Are there features in Shale which would make this possible? Is this
> where the Application Manager would come into play?
> 
> 
> 
> Thank you,
> 
> Brad
> 
> 


SV: URLs and backing beans

Posted by Hermod Opstvedt <he...@opstvedt.com>.
Hi

I'm not shure what you are looking for her but his is my understanding of
it.

Why would you want a backing bean for this? This is more the responsibility
of an ApplicationController. What I would do is to subclass the Shale
Aplication controller and add the logic you want there. You can use the
filter mappings to control what gets routed to you

Backing beans (I take it you mean ViewControllers) are mapped against views
i.e page2.jsf, page2.jsf and so on.

Hermod

-----Opprinnelig melding-----
Fra: Brad Smith [mailto:bgsmith@bendcable.com] 
Sendt: 24. mars 2007 15:36
Til: user@shale.apache.org
Emne: URLs and backing beans

I have an application which needs to handle urls that have the following
patterns:

http://localhost:8080/myapp/projects/office1

http://localhost:8080/myapp/projects/office2

http://localhost:8080/myapp/projects/office2/subofficeA

Conceptually I would like the request to be routed to a single backing
bean called Projects that would use the URL content after ../projects/..
to determine what the response should be.

Are there features in Shale which would make this possible? Is this
where the Application Manager would come into play?



Thank you,

Brad



Re: URLs and backing beans

Posted by Brad Smith <bg...@bendcable.com>.
Thanks Craig. Your suggestion on URL syntax is better.  It would be very
useful to have a simple RESTful URL mechanism in JSF.

Greetings from Bend.

Brad


On Sun, 2007-03-25 at 16:44 -0700, Craig McClanahan wrote:

> Perhaps
> 
>   http://localhost:8080/myapp/projects/office2.html
> 
> might be a little better?
> 
> Shale Remoting will get you part ways towards RESTful URLs with JSF,
> but by no means all the way.  One thing you'll find, for example, is
> that Shale Remoting dispenses with the idea of saving and restoring
> the state of the component tree, because the use case it was designed
> for (back end of Ajax transactions or static resource retrieval) does
> not need this.
> 
> It would be an interesting idea to contemplate exactly what it would
> take to create an environment that creates RESTful URLs as simply as,
> say, recent Rails versions can do it.  My bet is this wouldn't take a
> large amount of code ... in the mean time, you can probably get quite
> a ways.
> 



Re: URLs and backing beans

Posted by Brad Smith <bg...@bendcable.com>.
While looking further into this issue I ran across this web page:

http://www.jsffaq.com/Wiki.jsp?page=HowToMaskActualURLToTheJSFPage

which is a copy of the response in this forum thread:

http://forum.java.sun.com/thread.jspa?forumID=427&threadID=511578

The solution advocated here is a custom ViewHandler.  This would seem to
be more upfront work than using Shale Remoting but a better fit into the
JSF mechanism.  The question I am working on now, is how to get this to
work with the Facelets ViewHandler (both would use a decorator pattern)
via the standard faces-config.xml and/or web.xml.

This takes this thread away from Shale, but I thought I would cap the
thread with my current thinking on this.

Brad


On Sun, 2007-03-25 at 16:44 -0700, Craig McClanahan wrote:

> It would be an interesting idea to contemplate exactly what it would
> take to create an environment that creates RESTful URLs as simply as,
> say, recent Rails versions can do it.  My bet is this wouldn't take a
> large amount of code ... in the mean time, you can probably get quite
> a ways.
> 
> Craig



Re: URLs and backing beans

Posted by Craig McClanahan <cr...@apache.org>.
On 3/25/07, Brad Smith <bg...@bendcable.com> wrote:
> Thanks Kito.  I was also considering a servlet filter approach but am
> leaning towards a custom Processor implementation based on Shale's
> remoting as you and Rahul recommend.
>
> My only lingering concern is the need to have the url end in the same
> extension that the JSF servlet is expecting (html in this case). I
> suppose I could append an "index.html" on every URL but that has a
> slight code "smell".  :)
>
> That is Remoting (and JSF) will require
>
> http://localhost:8080/myapp/projects/office2/index.html
>
> instead of
>
> http://localhost:8080/myapp/projects/office2
>
> in order to properly process the request.
>

Perhaps

  http://localhost:8080/myapp/projects/office2.html

might be a little better?

Shale Remoting will get you part ways towards RESTful URLs with JSF,
but by no means all the way.  One thing you'll find, for example, is
that Shale Remoting dispenses with the idea of saving and restoring
the state of the component tree, because the use case it was designed
for (back end of Ajax transactions or static resource retrieval) does
not need this.

It would be an interesting idea to contemplate exactly what it would
take to create an environment that creates RESTful URLs as simply as,
say, recent Rails versions can do it.  My bet is this wouldn't take a
large amount of code ... in the mean time, you can probably get quite
a ways.

Craig


> Brad
>
>
> On Sat, 2007-03-24 at 17:24 -0400, Kito D. Mann wrote:
> > Brad,
> >
> > I often use a Servlet filter for this type of stuff, but a cleaner approach
> > might be to use Shale Remoting (http://shale.apache.org/remoting). The
> > process() method in your MethodBindingProcessor
> > (http://shale.apache.org/1.0.4/shale-remoting/apidocs/org/apache/shale/remot
> > ing/impl/MethodBindingProcessor) implementation could load the projects, set
> > the veiw id, and jump to the render response phase.
>
>
>

RE: URLs and backing beans

Posted by Brad Smith <bg...@bendcable.com>.
Thanks Kito.  I was also considering a servlet filter approach but am
leaning towards a custom Processor implementation based on Shale's
remoting as you and Rahul recommend.

My only lingering concern is the need to have the url end in the same
extension that the JSF servlet is expecting (html in this case). I
suppose I could append an "index.html" on every URL but that has a
slight code "smell".  :)

That is Remoting (and JSF) will require

http://localhost:8080/myapp/projects/office2/index.html

instead of

http://localhost:8080/myapp/projects/office2

in order to properly process the request.

Brad


On Sat, 2007-03-24 at 17:24 -0400, Kito D. Mann wrote:
> Brad,
> 
> I often use a Servlet filter for this type of stuff, but a cleaner approach
> might be to use Shale Remoting (http://shale.apache.org/remoting). The
> process() method in your MethodBindingProcessor
> (http://shale.apache.org/1.0.4/shale-remoting/apidocs/org/apache/shale/remot
> ing/impl/MethodBindingProcessor) implementation could load the projects, set
> the veiw id, and jump to the render response phase.



RE: URLs and backing beans

Posted by "Kito D. Mann" <km...@virtua.com>.
Brad,

I often use a Servlet filter for this type of stuff, but a cleaner approach
might be to use Shale Remoting (http://shale.apache.org/remoting). The
process() method in your MethodBindingProcessor
(http://shale.apache.org/1.0.4/shale-remoting/apidocs/org/apache/shale/remot
ing/impl/MethodBindingProcessor) implementation could load the projects, set
the veiw id, and jump to the render response phase.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kito D. Mann - Author, JavaServer Faces in Action
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info

* Sign up for the JSF Central newsletter!
http://oi.vresp.com/?fid=ac048d0e17 *



 

> -----Original Message-----
> From: Brad Smith [mailto:bgsmith@bendcable.com] 
> Sent: Saturday, March 24, 2007 10:36 AM
> To: user@shale.apache.org
> Subject: URLs and backing beans
> 
> I have an application which needs to handle urls that have 
> the following
> patterns:
> 
> http://localhost:8080/myapp/projects/office1
> 
> http://localhost:8080/myapp/projects/office2
> 
> http://localhost:8080/myapp/projects/office2/subofficeA
> 
> Conceptually I would like the request to be routed to a 
> single backing bean called Projects that would use the URL 
> content after ../projects/..
> to determine what the response should be.
> 
> Are there features in Shale which would make this possible? 
> Is this where the Application Manager would come into play?
> 
> 
> 
> Thank you,
> 
> Brad
>