Skip to main content

[webtier] Way to "Find" Faces Servlet?

18 replies [Last post]
Anonymous

I'm trying to figure out a way to dispatch a request to Faces Servlet,
but I'm not sure how to discover how Faces Servlet is mapped. Is there
any way to do this?

Basically, I want to be able to do something like this:

1. Request comes in for /some/url/
2. Filter intercepts /some/url/ and understands that it belongs to Faces
3. Filter forwards request to Faces Servlet (even though Faces Servlet
is not mapped to /some/url/ )

So that means that I need either a blind forward, or a way of
determining some URL that *does* resolve to Faces Servlet. Once the
request is in Faces, it does not matter that there is no view file
corresponding to the address.

Thanks,
Lincoln

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jim Driscoll

That's often the way such things are handled. Without knowing other
details, I can't say if that's the best way... but it probably is.

Jim

On 1/7/10 7:51 AM, Celinio Fernandes wrote:
> well,
> i managed to handle it with a servlet and the tag.
> Someone knows better ?
>
>
> --- On *Thu, 1/7/10, Celinio Fernandes /
/* wrote:
>
>
> From: Celinio Fernandes
> Subject: [webtier] Blob image and JSF 2
> To: webtier@glassfish.dev.java.net
> Date: Thursday, January 7, 2010, 8:09 PM
>
> Hi,
> I have an image which is stored in a database. It is mapped to a
> Blob variable in an entity bean.
> Before digging further into the documentation, I thought I'd ask here :
> is there a standard or a recommended way to handle a Blob image in
> JSF 2 ?
>
> Thanks.
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Lincoln Baxter, III

You can simply access the HttpServletResponse OutputStream directly from a
faces-javaBean method, called when a specific JSF viewId (the URL of the
image) is accessed... from there you can call
facesContext.responseComplete() after the image has been streamed. That's a
way around using a custom servlet, and still gaining access to the faces
lifecycle (should you choose.) though it will likely be less efficient than
a thin servlet-based implementation.

--Lincoln

On Thu, Jan 7, 2010 at 11:34 AM, Jim Driscoll wrote:

> That's often the way such things are handled. Without knowing other
> details, I can't say if that's the best way... but it probably is.
>
> Jim
>
>
> On 1/7/10 7:51 AM, Celinio Fernandes wrote:
>
>> well,
>> i managed to handle it with a servlet and the tag.
>> Someone knows better ?
>>
>>
>> --- On *Thu, 1/7/10, Celinio Fernandes /
/* wrote:
>>
>>
>> From: Celinio Fernandes
>> Subject: [webtier] Blob image and JSF 2
>> To: webtier@glassfish.dev.java.net
>> Date: Thursday, January 7, 2010, 8:09 PM
>>
>> Hi,
>> I have an image which is stored in a database. It is mapped to a
>> Blob variable in an entity bean.
>> Before digging further into the documentation, I thought I'd ask here :
>> is there a standard or a recommended way to handle a Blob image in
>> JSF 2 ?
>>
>> Thanks.
>>
>>
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
[att1.html]

Jason Lee

FWIW, Mojarra Scales has a component that will take care of that for you:

http://kenai.com/projects/scales/pages/Download

Version 1.3.x is 1.2-based, but should work in a 2.0 environment. If
you'd prefer a 2.0 version, you can use the SNAPSHOT in the java.net
Maven repo. While some components, most notably sc:dataTable are a bit
broken at the moment, most, including sc:download, should be very stable
in the SNAPSHOT.

On 1/7/10 10:42 AM, Lincoln Baxter, III wrote:
> You can simply access the HttpServletResponse OutputStream directly
> from a faces-javaBean method, called when a specific JSF viewId (the
> URL of the image) is accessed... from there you can call
> facesContext.responseComplete() after the image has been streamed.
> That's a way around using a custom servlet, and still gaining access
> to the faces lifecycle (should you choose.) though it will likely be
> less efficient than a thin servlet-based implementation.
>
> --Lincoln
>
> On Thu, Jan 7, 2010 at 11:34 AM, Jim Driscoll > > wrote:
>
> That's often the way such things are handled. Without knowing
> other details, I can't say if that's the best way... but it
> probably is.
>
> Jim
>
>
> On 1/7/10 7:51 AM, Celinio Fernandes wrote:
>
> well,
> i managed to handle it with a servlet and the
> tag.
> Someone knows better ?
>
>
> --- On *Thu, 1/7/10, Celinio Fernandes /
> >/* wrote:
>
>
> From: Celinio Fernandes
> >
> Subject: [webtier] Blob image and JSF 2
> To: webtier@glassfish.dev.java.net
>
> Date: Thursday, January 7, 2010, 8:09 PM
>
> Hi,
> I have an image which is stored in a database. It is mapped
> to a
> Blob variable in an entity bean.
> Before digging further into the documentation, I thought
> I'd ask here :
> is there a standard or a recommended way to handle a Blob
> image in
> JSF 2 ?
>
> Thanks.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
>
> For additional commands, e-mail:
> webtier-help@glassfish.dev.java.net
>
>
>
>
>
> --
> Lincoln Baxter, III
> http://ocpsoft.com
> http://scrumshark.com
> "Keep it Simple"

--
Jason Lee
Senior Java Developer
GlassFish Administration Console

Sun Microsystems, Inc.
Phone x31197/+1 405-343-1964
Email jasondlee@sun.com
Blog http://blogs.sun.com/jasondlee
Blog http://blogs.steeplesoft.com

[att1.html]

Ryan Lubke

If you're using Servlet 3.0, you can use the new programmatic APIs
available on the ServletContext to
obtain information on all registered Servlets.

Anything earlier than 3.0, probably means parsing the web.xml yourself.

On 1/3/10 12:23 PM, Lincoln Baxter, III wrote:
> I'm trying to figure out a way to dispatch a request to Faces Servlet,
> but I'm not sure how to discover how Faces Servlet is mapped. Is there
> any way to do this?
>
> Basically, I want to be able to do something like this:
>
> 1. Request comes in for /some/url/
> 2. Filter intercepts /some/url/ and understands that it belongs to Faces
> 3. Filter forwards request to Faces Servlet (even though Faces Servlet
> is not mapped to /some/url/ )
>
> So that means that I need either a blind forward, or a way of
> determining some URL that *does* resolve to Faces Servlet. Once the
> request is in Faces, it does not matter that there is no view file
> corresponding to the address.
>
> Thanks,
> Lincoln
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Lincoln Baxter, III

Any good examples out there on how to do this? Any reusable libs that you
know of?

I assume this is the identifier I would be looking for, then grab the
mapping and build a URL, since it's the spec'd (final/un-subclassable)
servlet-class.

*javax.faces.webapp.FacesServlet*

Additionally, I have a potentially basic Java question:

Just for confirmation, I can test this when I try it out: Assuming that I'm
using servletContext.getMajorVersion() to detect the current Servlet version
and take appropriate action, since I've never attempted to write a portable
lib between servlet versions... if I reference servlet 3.0, 2.5 APIs will
work in a 3.0 environment (unless deprecated), and make sure no 3.0 APIs are
accessed in 2.5 environments, I should be OK without runtime failures?

Thanks,
--Lincoln

On Mon, Jan 4, 2010 at 12:01 PM, Ryan Lubke wrote:

> If you're using Servlet 3.0, you can use the new programmatic APIs
> available on the ServletContext to
> obtain information on all registered Servlets.
>
> Anything earlier than 3.0, probably means parsing the web.xml yourself.
>
>
> On 1/3/10 12:23 PM, Lincoln Baxter, III wrote:
>
>> I'm trying to figure out a way to dispatch a request to Faces Servlet,
>> but I'm not sure how to discover how Faces Servlet is mapped. Is there
>> any way to do this?
>>
>> Basically, I want to be able to do something like this:
>>
>> 1. Request comes in for /some/url/
>> 2. Filter intercepts /some/url/ and understands that it belongs to Faces
>> 3. Filter forwards request to Faces Servlet (even though Faces Servlet
>> is not mapped to /some/url/ )
>>
>> So that means that I need either a blind forward, or a way of
>> determining some URL that *does* resolve to Faces Servlet. Once the
>> request is in Faces, it does not matter that there is no view file
>> corresponding to the address.
>>
>> Thanks,
>> Lincoln
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
[att1.html]

Ryan Lubke

On 1/4/10 2:02 PM, Lincoln Baxter, III wrote:
> Any good examples out there on how to do this? Any reusable libs that
> you know of?
Of the servlet 3.0 API?

Map existing =
servletContext.getServletRegistrations();
for (ServletRegistration registration : existing.values()) {
if
("javax.faces.webapp.FacesServlet".equals(registration.getClassName())) {
Collection mappings =
registration.getMappings();
// do something with the mappings.
}
}

>
> I assume this is the identifier I would be looking for, then grab the
> mapping and build a URL, since it's the spec'd (final/un-subclassable)
> servlet-class.
> *javax.faces.webapp.FacesServlet*
>
In 95% of the cases this would be true. However, there are some JSF
applications that wrap the FacesServlet so that they can provide custom
features. For example, the GlassFish admin gui has such a wrapper to
defer initialization until the first request to the servlet.

That said, relying on the servlet class vs the name is the better choice.
> Additionally, I have a potentially basic Java question:
>
> Just for confirmation, I can test this when I try it out: Assuming
> that I'm using servletContext.getMajorVersion() to detect the current
> Servlet version and take appropriate action, since I've never
> attempted to write a portable lib between servlet versions... if I
> reference servlet 3.0, 2.5 APIs will work in a 3.0 environment (unless
> deprecated), and make sure no 3.0 APIs are accessed in 2.5
> environments, I should be OK without runtime failures?
Mojarra does this. As long as you compile with the latest version and
guard against calling methods that shouldn't be depending on the
version, you'll be fine.
>
> Thanks,
> --Lincoln
>
>
> On Mon, Jan 4, 2010 at 12:01 PM, Ryan Lubke > > wrote:
>
> If you're using Servlet 3.0, you can use the new programmatic APIs
> available on the ServletContext to
> obtain information on all registered Servlets.
>
> Anything earlier than 3.0, probably means parsing the web.xml
> yourself.
>
>
> On 1/3/10 12:23 PM, Lincoln Baxter, III wrote:
>
> I'm trying to figure out a way to dispatch a request to Faces
> Servlet,
> but I'm not sure how to discover how Faces Servlet is mapped.
> Is there
> any way to do this?
>
> Basically, I want to be able to do something like this:
>
> 1. Request comes in for /some/url/
> 2. Filter intercepts /some/url/ and understands that it
> belongs to Faces
> 3. Filter forwards request to Faces Servlet (even though Faces
> Servlet
> is not mapped to /some/url/ )
>
> So that means that I need either a blind forward, or a way of
> determining some URL that *does* resolve to Faces Servlet.
> Once the
> request is in Faces, it does not matter that there is no view file
> corresponding to the address.
>
> Thanks,
> Lincoln
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> webtier-unsubscribe@glassfish.dev.java.net
>
> For additional commands, e-mail:
> webtier-help@glassfish.dev.java.net
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
>
> For additional commands, e-mail:
> webtier-help@glassfish.dev.java.net
>
>
>
>
>
> --
> Lincoln Baxter, III
> http://ocpsoft.com
> http://scrumshark.com
> "Keep it Simple"

[att1.html]

Lincoln Baxter, III

I was actually hoping for a pre-made web.xml parser ;) but I'll just figure
something out. This is a great start for the 3.0 stuff, though, thanks!

--lb

On Mon, Jan 4, 2010 at 5:26 PM, Ryan Lubke wrote:

> On 1/4/10 2:02 PM, Lincoln Baxter, III wrote:
>
> Any good examples out there on how to do this? Any reusable libs that you
> know of?
>
> Of the servlet 3.0 API?
>
> Map existing =
> servletContext.getServletRegistrations();
> for (ServletRegistration registration : existing.values()) {
> if
> ("javax.faces.webapp.FacesServlet".equals(registration.getClassName())) {
> Collection mappings =
> registration.getMappings();
> // do something with the mappings.
>
> }
> }
>
>
>
> I assume this is the identifier I would be looking for, then grab the
> mapping and build a URL, since it's the spec'd (final/un-subclassable)
> servlet-class.
>
> *javax.faces.webapp.FacesServlet*
>
>
> In 95% of the cases this would be true. However, there are some JSF
> applications that wrap the FacesServlet so that they can provide custom
> features. For example, the GlassFish admin gui has such a wrapper to defer
> initialization until the first request to the servlet.
>
> That said, relying on the servlet class vs the name is the better choice.
>
> Additionally, I have a potentially basic Java question:
>
> Just for confirmation, I can test this when I try it out: Assuming that I'm
> using servletContext.getMajorVersion() to detect the current Servlet version
> and take appropriate action, since I've never attempted to write a portable
> lib between servlet versions... if I reference servlet 3.0, 2.5 APIs will
> work in a 3.0 environment (unless deprecated), and make sure no 3.0 APIs are
> accessed in 2.5 environments, I should be OK without runtime failures?
>
> Mojarra does this. As long as you compile with the latest version and
> guard against calling methods that shouldn't be depending on the version,
> you'll be fine.
>
>
> Thanks,
> --Lincoln
>
>
> On Mon, Jan 4, 2010 at 12:01 PM, Ryan Lubke wrote:
>
>> If you're using Servlet 3.0, you can use the new programmatic APIs
>> available on the ServletContext to
>> obtain information on all registered Servlets.
>>
>> Anything earlier than 3.0, probably means parsing the web.xml yourself.
>>
>>
>> On 1/3/10 12:23 PM, Lincoln Baxter, III wrote:
>>
>>> I'm trying to figure out a way to dispatch a request to Faces Servlet,
>>> but I'm not sure how to discover how Faces Servlet is mapped. Is there
>>> any way to do this?
>>>
>>> Basically, I want to be able to do something like this:
>>>
>>> 1. Request comes in for /some/url/
>>> 2. Filter intercepts /some/url/ and understands that it belongs to Faces
>>> 3. Filter forwards request to Faces Servlet (even though Faces Servlet
>>> is not mapped to /some/url/ )
>>>
>>> So that means that I need either a blind forward, or a way of
>>> determining some URL that *does* resolve to Faces Servlet. Once the
>>> request is in Faces, it does not matter that there is no view file
>>> corresponding to the address.
>>>
>>> Thanks,
>>> Lincoln
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
>>> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>>
>>
>
>
> --
> Lincoln Baxter, III
> http://ocpsoft.com
> http://scrumshark.com
> "Keep it Simple"
>
>
>

--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
[att1.html]

Celinio Fernandes

Hi,

one of the ways to do Ajax with JSF 2 is to use this tag :

    

But where is the JavaScript library jsf.js located ?

Thanks

[att1.html]

rogerk
Offline
Joined: 2004-05-06
Points: 0

The jsf.js JavaScript library is under the jsf-api/src/main/resources directory bundled in mojarra.

rogerk
Offline
Joined: 2004-05-06
Points: 0

Further clarification:

That was the source location. Here is the run time location:

META-INF/resources/javax.faces/jsf.js in jsf-impl.jar

Celinio Fernandes

Thanks for this information. I quickly checked these 2 files before asking the question but did not think about checking inside the javax.faces folder.

--- On Wed, 1/6/10, webtier@javadesktop.org wrote:

From: webtier@javadesktop.org
Subject: Re: [webtier] Ajax : where is jsf.js ?
To: webtier@glassfish.dev.java.net
Date: Wednesday, January 6, 2010, 11:56 PM

Further clarification:

That was the source location.  Here is the run time location:

META-INF/resources/javax.faces/jsf.js in jsf-impl.jar
[Message sent by forum member 'rogerk' (roger.kitain@sun.com)]

http://forums.java.net/jive/thread.jspa?messageID=379074

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

[att1.html]

Celinio Fernandes

Hi,
I have an image which is stored in a database. It is mapped to a Blob variable in an entity bean.
Before digging further into the documentation, I thought I'd ask here :
is there a standard or a recommended way to handle a Blob image in JSF 2 ?

Thanks.

[att1.html]

Celinio Fernandes

well,
i managed to handle it with a servlet and the tag.
Someone knows better ?

--- On Thu, 1/7/10, Celinio Fernandes
wrote:

From: Celinio Fernandes
Subject: [webtier] Blob image and JSF 2
To: webtier@glassfish.dev.java.net
Date: Thursday, January 7, 2010, 8:09 PM

Hi,
I have an image which is stored in a database. It is mapped to a Blob variable in an entity bean.
Before digging further into the documentation, I thought I'd ask here :
is there a standard or a recommended way to handle a Blob image in JSF 2 ?

Thanks.

[att1.html]

Celinio Fernandes

Hi,

in JSF 2, what are the steps to create a custom component with EZComp ?

Can't find any detailed example.

Thanks.

[att1.html]

Jim Driscoll

The Mojarra demos are filled with them...

On 1/7/10 7:52 AM, Celinio Fernandes wrote:
> Hi,
> in JSF 2, what are the steps to create a custom component with EZComp ?
> Can't find any detailed example.
>
> Thanks.
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Lincoln Baxter, III

Try this:

http://andyschwartz.wordpress.com/2009/07/31/whats-new-in-jsf-2/#composi...

--Lincoln

On Thu, Jan 7, 2010 at 11:32 AM, Jim Driscoll wrote:

> The Mojarra demos are filled with them...
>
>
> On 1/7/10 7:52 AM, Celinio Fernandes wrote:
>
>> Hi,
>> in JSF 2, what are the steps to create a custom component with EZComp ?
>> Can't find any detailed example.
>>
>> Thanks.
>>
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
[att1.html]

Celinio Fernandes

thanks.

--- On Fri, 1/8/10, Lincoln Baxter, III
wrote:

From: Lincoln Baxter, III
Subject: Re: [webtier] [JSF 2] Steps to create a custom component with EZComp ?
To: webtier@glassfish.dev.java.net
Date: Friday, January 8, 2010, 12:13 PM

Try this:

http://andyschwartz.wordpress.com/2009/07/31/whats-new-in-jsf-2/#composi...

--Lincoln

On Thu, Jan 7, 2010 at 11:32 AM, Jim Driscoll wrote:

The Mojarra demos are filled with them...

On 1/7/10 7:52 AM, Celinio Fernandes wrote:

Hi,

in JSF 2, what are the steps to create a custom component with EZComp ?

Can't find any detailed example.

Thanks.

---------------------------------------------------------------------

To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net

For additional commands, e-mail: webtier-help@glassfish.dev.java.net

--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"

[att1.html]

Celinio Fernandes

Hi,
I am probably not looking where i should but i am going to ask anyways.
I am reading the JavaServer Faces Specification, final draft (20090625).

I do not see any mention of the annotations (@managedbean, @ViewScoped, etc ...)

How come you did not mention them in the specification ?
Thanks.

[att1.html]