Creating URLs referencing a JSF application

View: New views
15 Messages — Rating Filter:   Alert me  

Creating URLs referencing a JSF application

by Bill-124 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

  I've gotten a request for one of my JSF applications for users to be
able to directly link to pages within the application.  The
application simply takes a bunch of form inputs and returns some
images derived from these inputs...it doesn't require any 'state'
information so it should be pretty straightforward.

  Is there a way to do this without having to manually create a GET
type URL myself?  I start doing this, but it became apparent that this
would be very tedious...

-Bill

Re: Creating URLs referencing a JSF application

by Rick Fincher :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Bill,

Do you mean you want to redirect to another pre-existing page as in:

          try {
                ExternalContext externalContext =
getFacesContext().getExternalContext();
               
                String pageURL =
externalContext.getRequestContextPath()  +"/faces/YourPage.jsp";
                externalContext.redirect(pageURL);
            } catch(IOException ioe) {
                ioe.printStackTrace(System.out);
                System.out.println(ioe.toString());
            }

Or do you mean you want to load an image file based on what the users
select?

Rick


Bill wrote:

> Hi all,
>
>   I've gotten a request for one of my JSF applications for users to be
> able to directly link to pages within the application.  The
> application simply takes a bunch of form inputs and returns some
> images derived from these inputs...it doesn't require any 'state'
> information so it should be pretty straightforward.
>
>   Is there a way to do this without having to manually create a GET
> type URL myself?  I start doing this, but it became apparent that this
> would be very tedious...
>
> -Bill
>  


Re: Creating URLs referencing a JSF application

by Bill-124 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lets say you have 2 pulldowns, with id's "pd1" and "pd2" on a page
"page.jsp" for your website "www.example.com".  If you create a form
using these and submit then, there is no 'GET' type of url for them to
bookmark, copy/paste.  You'd simply be on the same page:

http://www.example.com/page.jsp

So I'm looking for something that will automatically create this URL
for me like:

http://www.example.com/page.jsp?pd1=selection1&pd2=selection2

On Thu, Jul 17, 2008 at 7:39 PM, Rick Fincher <rnf@...> wrote:

> Hi Bill,
>
> Do you mean you want to redirect to another pre-existing page as in:
>
>         try {
>               ExternalContext externalContext =
> getFacesContext().getExternalContext();
>                             String pageURL =
> externalContext.getRequestContextPath()  +"/faces/YourPage.jsp";
>               externalContext.redirect(pageURL);
>           } catch(IOException ioe) {
>               ioe.printStackTrace(System.out);
>               System.out.println(ioe.toString());
>           }
>
> Or do you mean you want to load an image file based on what the users
> select?
>
> Rick
>
>
> Bill wrote:
>>
>> Hi all,
>>
>>  I've gotten a request for one of my JSF applications for users to be
>> able to directly link to pages within the application.  The
>> application simply takes a bunch of form inputs and returns some
>> images derived from these inputs...it doesn't require any 'state'
>> information so it should be pretty straightforward.
>>
>>  Is there a way to do this without having to manually create a GET
>> type URL myself?  I start doing this, but it became apparent that this
>> would be very tedious...
>>
>> -Bill
>>
>
>

Re: Creating URLs referencing a JSF application

by Bill-124 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Anyone have any ideas?  Am I not explaining this clearly?

I would think linking into a JSF application, with arguments in the
URL, would be a pretty common usage...

On Thu, Jul 17, 2008 at 9:44 PM, Bill <saxton@...> wrote:

> Lets say you have 2 pulldowns, with id's "pd1" and "pd2" on a page
> "page.jsp" for your website "www.example.com".  If you create a form
> using these and submit then, there is no 'GET' type of url for them to
> bookmark, copy/paste.  You'd simply be on the same page:
>
> http://www.example.com/page.jsp
>
> So I'm looking for something that will automatically create this URL
> for me like:
>
> http://www.example.com/page.jsp?pd1=selection1&pd2=selection2
>
> On Thu, Jul 17, 2008 at 7:39 PM, Rick Fincher <rnf@...> wrote:
>> Hi Bill,
>>
>> Do you mean you want to redirect to another pre-existing page as in:
>>
>>         try {
>>               ExternalContext externalContext =
>> getFacesContext().getExternalContext();
>>                             String pageURL =
>> externalContext.getRequestContextPath()  +"/faces/YourPage.jsp";
>>               externalContext.redirect(pageURL);
>>           } catch(IOException ioe) {
>>               ioe.printStackTrace(System.out);
>>               System.out.println(ioe.toString());
>>           }
>>
>> Or do you mean you want to load an image file based on what the users
>> select?
>>
>> Rick
>>
>>
>> Bill wrote:
>>>
>>> Hi all,
>>>
>>>  I've gotten a request for one of my JSF applications for users to be
>>> able to directly link to pages within the application.  The
>>> application simply takes a bunch of form inputs and returns some
>>> images derived from these inputs...it doesn't require any 'state'
>>> information so it should be pretty straightforward.
>>>
>>>  Is there a way to do this without having to manually create a GET
>>> type URL myself?  I start doing this, but it became apparent that this
>>> would be very tedious...
>>>
>>> -Bill
>>>
>>
>>
>

Re: Creating URLs referencing a JSF application

by Karthikeyan Rajeswaran :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't think i am understanding the question correctly; but , in
page.jsp , can you try
'response.sendRedirect("http://www.example.com?pd1=selection");

Alternatively, you could have a 'Create URL' button on the page that can
construct the url and show it to the user.

Of course,  within a web application, one needs to be careful and ensure
that a bookmarked page can be accessed independently. For instance, if
the webapp requires a login, then when a user accesses a page directly
with a set of parameters and has not logged in yet, the page should
preferably show the login page to the user.

regards,
karthik



Bill wrote:

> Anyone have any ideas?  Am I not explaining this clearly?
>
> I would think linking into a JSF application, with arguments in the
> URL, would be a pretty common usage...
>
> On Thu, Jul 17, 2008 at 9:44 PM, Bill <saxton@...> wrote:
>  
>> Lets say you have 2 pulldowns, with id's "pd1" and "pd2" on a page
>> "page.jsp" for your website "www.example.com".  If you create a form
>> using these and submit then, there is no 'GET' type of url for them to
>> bookmark, copy/paste.  You'd simply be on the same page:
>>
>> http://www.example.com/page.jsp
>>
>> So I'm looking for something that will automatically create this URL
>> for me like:
>>
>> http://www.example.com/page.jsp?pd1=selection1&pd2=selection2
>>
>> On Thu, Jul 17, 2008 at 7:39 PM, Rick Fincher <rnf@...> wrote:
>>    
>>> Hi Bill,
>>>
>>> Do you mean you want to redirect to another pre-existing page as in:
>>>
>>>         try {
>>>               ExternalContext externalContext =
>>> getFacesContext().getExternalContext();
>>>                             String pageURL =
>>> externalContext.getRequestContextPath()  +"/faces/YourPage.jsp";
>>>               externalContext.redirect(pageURL);
>>>           } catch(IOException ioe) {
>>>               ioe.printStackTrace(System.out);
>>>               System.out.println(ioe.toString());
>>>           }
>>>
>>> Or do you mean you want to load an image file based on what the users
>>> select?
>>>
>>> Rick
>>>
>>>
>>> Bill wrote:
>>>      
>>>> Hi all,
>>>>
>>>>  I've gotten a request for one of my JSF applications for users to be
>>>> able to directly link to pages within the application.  The
>>>> application simply takes a bunch of form inputs and returns some
>>>> images derived from these inputs...it doesn't require any 'state'
>>>> information so it should be pretty straightforward.
>>>>
>>>>  Is there a way to do this without having to manually create a GET
>>>> type URL myself?  I start doing this, but it became apparent that this
>>>> would be very tedious...
>>>>
>>>> -Bill
>>>>
>>>>        
>>>      

Re: Creating URLs referencing a JSF application

by Bill-124 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Karthik,

  This is exactly my point...Can JSF construct this URL already or do
I have to do it manually and parse the arguments myself??

  I started doing this manually, which is pretty easy for pulldowns
and the like, but what happens when the users suddenly have JSF
component Date fields to deal with?  JSF handles the input as a Date
class, so now I'd have to write a String to Date converter to convert
a date in a String argument to a Date class in my code.

  I know this can be done...I just didn't want to have to do all this
manual work which JSF is supposed to eliminate!

-Bill

On Fri, Jul 18, 2008 at 1:18 PM, Karthik <Karthikeyan.Rajeswaran@...> wrote:

> I don't think i am understanding the question correctly; but , in page.jsp ,
> can you try 'response.sendRedirect("http://www.example.com?pd1=selection");
>
> Alternatively, you could have a 'Create URL' button on the page that can
> construct the url and show it to the user.
>
> Of course,  within a web application, one needs to be careful and ensure
> that a bookmarked page can be accessed independently. For instance, if the
> webapp requires a login, then when a user accesses a page directly with a
> set of parameters and has not logged in yet, the page should preferably show
> the login page to the user.
>
> regards,
> karthik
>
>
>
> Bill wrote:
>>
>> Anyone have any ideas?  Am I not explaining this clearly?
>>
>> I would think linking into a JSF application, with arguments in the
>> URL, would be a pretty common usage...
>>
>> On Thu, Jul 17, 2008 at 9:44 PM, Bill <saxton@...> wrote:
>>
>>>
>>> Lets say you have 2 pulldowns, with id's "pd1" and "pd2" on a page
>>> "page.jsp" for your website "www.example.com".  If you create a form
>>> using these and submit then, there is no 'GET' type of url for them to
>>> bookmark, copy/paste.  You'd simply be on the same page:
>>>
>>> http://www.example.com/page.jsp
>>>
>>> So I'm looking for something that will automatically create this URL
>>> for me like:
>>>
>>> http://www.example.com/page.jsp?pd1=selection1&pd2=selection2
>>>
>>> On Thu, Jul 17, 2008 at 7:39 PM, Rick Fincher <rnf@...> wrote:
>>>
>>>>
>>>> Hi Bill,
>>>>
>>>> Do you mean you want to redirect to another pre-existing page as in:
>>>>
>>>>        try {
>>>>              ExternalContext externalContext =
>>>> getFacesContext().getExternalContext();
>>>>                            String pageURL =
>>>> externalContext.getRequestContextPath()  +"/faces/YourPage.jsp";
>>>>              externalContext.redirect(pageURL);
>>>>          } catch(IOException ioe) {
>>>>              ioe.printStackTrace(System.out);
>>>>              System.out.println(ioe.toString());
>>>>          }
>>>>
>>>> Or do you mean you want to load an image file based on what the users
>>>> select?
>>>>
>>>> Rick
>>>>
>>>>
>>>> Bill wrote:
>>>>
>>>>>
>>>>> Hi all,
>>>>>
>>>>>  I've gotten a request for one of my JSF applications for users to be
>>>>> able to directly link to pages within the application.  The
>>>>> application simply takes a bunch of form inputs and returns some
>>>>> images derived from these inputs...it doesn't require any 'state'
>>>>> information so it should be pretty straightforward.
>>>>>
>>>>>  Is there a way to do this without having to manually create a GET
>>>>> type URL myself?  I start doing this, but it became apparent that this
>>>>> would be very tedious...
>>>>>
>>>>> -Bill
>>>>>
>>>>>
>>>>
>>>>
>

Re: Creating URLs referencing a JSF application

by Karthikeyan Rajeswaran :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html#getQueryString()
   
Does it help?

regards,
karthik

Bill wrote:

> Hi Karthik,
>
>   This is exactly my point...Can JSF construct this URL already or do
> I have to do it manually and parse the arguments myself??
>
>   I started doing this manually, which is pretty easy for pulldowns
> and the like, but what happens when the users suddenly have JSF
> component Date fields to deal with?  JSF handles the input as a Date
> class, so now I'd have to write a String to Date converter to convert
> a date in a String argument to a Date class in my code.
>
>   I know this can be done...I just didn't want to have to do all this
> manual work which JSF is supposed to eliminate!
>
> -Bill
>
> On Fri, Jul 18, 2008 at 1:18 PM, Karthik <Karthikeyan.Rajeswaran@...> wrote:
>  
>> I don't think i am understanding the question correctly; but , in page.jsp ,
>> can you try 'response.sendRedirect("http://www.example.com?pd1=selection");
>>
>> Alternatively, you could have a 'Create URL' button on the page that can
>> construct the url and show it to the user.
>>
>> Of course,  within a web application, one needs to be careful and ensure
>> that a bookmarked page can be accessed independently. For instance, if the
>> webapp requires a login, then when a user accesses a page directly with a
>> set of parameters and has not logged in yet, the page should preferably show
>> the login page to the user.
>>
>> regards,
>> karthik
>>
>>
>>
>> Bill wrote:
>>    
>>> Anyone have any ideas?  Am I not explaining this clearly?
>>>
>>> I would think linking into a JSF application, with arguments in the
>>> URL, would be a pretty common usage...
>>>
>>> On Thu, Jul 17, 2008 at 9:44 PM, Bill <saxton@...> wrote:
>>>
>>>      
>>>> Lets say you have 2 pulldowns, with id's "pd1" and "pd2" on a page
>>>> "page.jsp" for your website "www.example.com".  If you create a form
>>>> using these and submit then, there is no 'GET' type of url for them to
>>>> bookmark, copy/paste.  You'd simply be on the same page:
>>>>
>>>> http://www.example.com/page.jsp
>>>>
>>>> So I'm looking for something that will automatically create this URL
>>>> for me like:
>>>>
>>>> http://www.example.com/page.jsp?pd1=selection1&pd2=selection2
>>>>
>>>> On Thu, Jul 17, 2008 at 7:39 PM, Rick Fincher <rnf@...> wrote:
>>>>
>>>>        
>>>>> Hi Bill,
>>>>>
>>>>> Do you mean you want to redirect to another pre-existing page as in:
>>>>>
>>>>>        try {
>>>>>              ExternalContext externalContext =
>>>>> getFacesContext().getExternalContext();
>>>>>                            String pageURL =
>>>>> externalContext.getRequestContextPath()  +"/faces/YourPage.jsp";
>>>>>              externalContext.redirect(pageURL);
>>>>>          } catch(IOException ioe) {
>>>>>              ioe.printStackTrace(System.out);
>>>>>              System.out.println(ioe.toString());
>>>>>          }
>>>>>
>>>>> Or do you mean you want to load an image file based on what the users
>>>>> select?
>>>>>
>>>>> Rick
>>>>>
>>>>>
>>>>> Bill wrote:
>>>>>
>>>>>          
>>>>>> Hi all,
>>>>>>
>>>>>>  I've gotten a request for one of my JSF applications for users to be
>>>>>> able to directly link to pages within the application.  The
>>>>>> application simply takes a bunch of form inputs and returns some
>>>>>> images derived from these inputs...it doesn't require any 'state'
>>>>>> information so it should be pretty straightforward.
>>>>>>
>>>>>>  Is there a way to do this without having to manually create a GET
>>>>>> type URL myself?  I start doing this, but it became apparent that this
>>>>>> would be very tedious...
>>>>>>
>>>>>> -Bill
>>>>>>
>>>>>>
>>>>>>            
>>>>>          

Re: Creating URLs referencing a JSF application

by Bill-124 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't have a problem getting the query string.  The problem is that
JSF does not create a query string for a form submission so there is
no query string to get.

As I posted in my earlier example, lets say I have 2 pulldowns "pd1"
and "pd2".  In "pd1" I select "optionA".  In "pd2" I select "optionB"
and submit the form.

The application DOES NOT create a query string like
"?pd1=optionA&pd2=optionB".  If you look @ the URL @ the top of the
browser, there is no query string.  So there is no way that I know of
to allow a user to revisit that submitted form page via a bookmark or
direct link.  Instead, every time they want to go to the page where
pd1 = optionA and pd2 = optionB, they have to select the options in
the pulldowns and submit the page.

I don't want them to have to do this!  I want to be able to give them
a link that does this form them.

Does this make sense?

On Fri, Jul 18, 2008 at 1:31 PM, Karthik <Karthikeyan.Rajeswaran@...> wrote:

> http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html#getQueryString()
>  Does it help?
>
> regards,
> karthik
>
> Bill wrote:
>>
>> Hi Karthik,
>>
>>  This is exactly my point...Can JSF construct this URL already or do
>> I have to do it manually and parse the arguments myself??
>>
>>  I started doing this manually, which is pretty easy for pulldowns
>> and the like, but what happens when the users suddenly have JSF
>> component Date fields to deal with?  JSF handles the input as a Date
>> class, so now I'd have to write a String to Date converter to convert
>> a date in a String argument to a Date class in my code.
>>
>>  I know this can be done...I just didn't want to have to do all this
>> manual work which JSF is supposed to eliminate!
>>
>> -Bill
>>
>> On Fri, Jul 18, 2008 at 1:18 PM, Karthik <Karthikeyan.Rajeswaran@...>
>> wrote:
>>
>>>
>>> I don't think i am understanding the question correctly; but , in
>>> page.jsp ,
>>> can you try
>>> 'response.sendRedirect("http://www.example.com?pd1=selection");
>>>
>>> Alternatively, you could have a 'Create URL' button on the page that can
>>> construct the url and show it to the user.
>>>
>>> Of course,  within a web application, one needs to be careful and ensure
>>> that a bookmarked page can be accessed independently. For instance, if
>>> the
>>> webapp requires a login, then when a user accesses a page directly with a
>>> set of parameters and has not logged in yet, the page should preferably
>>> show
>>> the login page to the user.
>>>
>>> regards,
>>> karthik
>>>
>>>
>>>
>>> Bill wrote:
>>>
>>>>
>>>> Anyone have any ideas?  Am I not explaining this clearly?
>>>>
>>>> I would think linking into a JSF application, with arguments in the
>>>> URL, would be a pretty common usage...
>>>>
>>>> On Thu, Jul 17, 2008 at 9:44 PM, Bill <saxton@...> wrote:
>>>>
>>>>
>>>>>
>>>>> Lets say you have 2 pulldowns, with id's "pd1" and "pd2" on a page
>>>>> "page.jsp" for your website "www.example.com".  If you create a form
>>>>> using these and submit then, there is no 'GET' type of url for them to
>>>>> bookmark, copy/paste.  You'd simply be on the same page:
>>>>>
>>>>> http://www.example.com/page.jsp
>>>>>
>>>>> So I'm looking for something that will automatically create this URL
>>>>> for me like:
>>>>>
>>>>> http://www.example.com/page.jsp?pd1=selection1&pd2=selection2
>>>>>
>>>>> On Thu, Jul 17, 2008 at 7:39 PM, Rick Fincher <rnf@...> wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> Hi Bill,
>>>>>>
>>>>>> Do you mean you want to redirect to another pre-existing page as in:
>>>>>>
>>>>>>       try {
>>>>>>             ExternalContext externalContext =
>>>>>> getFacesContext().getExternalContext();
>>>>>>                           String pageURL =
>>>>>> externalContext.getRequestContextPath()  +"/faces/YourPage.jsp";
>>>>>>             externalContext.redirect(pageURL);
>>>>>>         } catch(IOException ioe) {
>>>>>>             ioe.printStackTrace(System.out);
>>>>>>             System.out.println(ioe.toString());
>>>>>>         }
>>>>>>
>>>>>> Or do you mean you want to load an image file based on what the users
>>>>>> select?
>>>>>>
>>>>>> Rick
>>>>>>
>>>>>>
>>>>>> Bill wrote:
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>>  I've gotten a request for one of my JSF applications for users to be
>>>>>>> able to directly link to pages within the application.  The
>>>>>>> application simply takes a bunch of form inputs and returns some
>>>>>>> images derived from these inputs...it doesn't require any 'state'
>>>>>>> information so it should be pretty straightforward.
>>>>>>>
>>>>>>>  Is there a way to do this without having to manually create a GET
>>>>>>> type URL myself?  I start doing this, but it became apparent that
>>>>>>> this
>>>>>>> would be very tedious...
>>>>>>>
>>>>>>> -Bill
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>

Re: Creating URLs referencing a JSF application

by Karthikeyan Rajeswaran :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> Does this make sense?
It does. (And hopefully some one more knowledgeable will jump in...)

Would getParameterMap() help in constructing the URL yourself?
   
http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameterMap()

thanks,
karthik

Bill wrote:

> I don't have a problem getting the query string.  The problem is that
> JSF does not create a query string for a form submission so there is
> no query string to get.
>
> As I posted in my earlier example, lets say I have 2 pulldowns "pd1"
> and "pd2".  In "pd1" I select "optionA".  In "pd2" I select "optionB"
> and submit the form.
>
> The application DOES NOT create a query string like
> "?pd1=optionA&pd2=optionB".  If you look @ the URL @ the top of the
> browser, there is no query string.  So there is no way that I know of
> to allow a user to revisit that submitted form page via a bookmark or
> direct link.  Instead, every time they want to go to the page where
> pd1 = optionA and pd2 = optionB, they have to select the options in
> the pulldowns and submit the page.
>
> I don't want them to have to do this!  I want to be able to give them
> a link that does this form them.
>
> Does this make sense?
>
> On Fri, Jul 18, 2008 at 1:31 PM, Karthik <Karthikeyan.Rajeswaran@...> wrote:
>  
>> http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html#getQueryString()
>>  Does it help?
>>
>> regards,
>> karthik
>>
>> Bill wrote:
>>    
>>> Hi Karthik,
>>>
>>>  This is exactly my point...Can JSF construct this URL already or do
>>> I have to do it manually and parse the arguments myself??
>>>
>>>  I started doing this manually, which is pretty easy for pulldowns
>>> and the like, but what happens when the users suddenly have JSF
>>> component Date fields to deal with?  JSF handles the input as a Date
>>> class, so now I'd have to write a String to Date converter to convert
>>> a date in a String argument to a Date class in my code.
>>>
>>>  I know this can be done...I just didn't want to have to do all this
>>> manual work which JSF is supposed to eliminate!
>>>
>>> -Bill
>>>
>>> On Fri, Jul 18, 2008 at 1:18 PM, Karthik <Karthikeyan.Rajeswaran@...>
>>> wrote:
>>>
>>>      
>>>> I don't think i am understanding the question correctly; but , in
>>>> page.jsp ,
>>>> can you try
>>>> 'response.sendRedirect("http://www.example.com?pd1=selection");
>>>>
>>>> Alternatively, you could have a 'Create URL' button on the page that can
>>>> construct the url and show it to the user.
>>>>
>>>> Of course,  within a web application, one needs to be careful and ensure
>>>> that a bookmarked page can be accessed independently. For instance, if
>>>> the
>>>> webapp requires a login, then when a user accesses a page directly with a
>>>> set of parameters and has not logged in yet, the page should preferably
>>>> show
>>>> the login page to the user.
>>>>
>>>> regards,
>>>> karthik
>>>>
>>>>
>>>>
>>>> Bill wrote:
>>>>
>>>>        
>>>>> Anyone have any ideas?  Am I not explaining this clearly?
>>>>>
>>>>> I would think linking into a JSF application, with arguments in the
>>>>> URL, would be a pretty common usage...
>>>>>
>>>>> On Thu, Jul 17, 2008 at 9:44 PM, Bill <saxton@...> wrote:
>>>>>
>>>>>
>>>>>          
>>>>>> Lets say you have 2 pulldowns, with id's "pd1" and "pd2" on a page
>>>>>> "page.jsp" for your website "www.example.com".  If you create a form
>>>>>> using these and submit then, there is no 'GET' type of url for them to
>>>>>> bookmark, copy/paste.  You'd simply be on the same page:
>>>>>>
>>>>>> http://www.example.com/page.jsp
>>>>>>
>>>>>> So I'm looking for something that will automatically create this URL
>>>>>> for me like:
>>>>>>
>>>>>> http://www.example.com/page.jsp?pd1=selection1&pd2=selection2
>>>>>>
>>>>>> On Thu, Jul 17, 2008 at 7:39 PM, Rick Fincher <rnf@...> wrote:
>>>>>>
>>>>>>
>>>>>>            
>>>>>>> Hi Bill,
>>>>>>>
>>>>>>> Do you mean you want to redirect to another pre-existing page as in:
>>>>>>>
>>>>>>>       try {
>>>>>>>             ExternalContext externalContext =
>>>>>>> getFacesContext().getExternalContext();
>>>>>>>                           String pageURL =
>>>>>>> externalContext.getRequestContextPath()  +"/faces/YourPage.jsp";
>>>>>>>             externalContext.redirect(pageURL);
>>>>>>>         } catch(IOException ioe) {
>>>>>>>             ioe.printStackTrace(System.out);
>>>>>>>             System.out.println(ioe.toString());
>>>>>>>         }
>>>>>>>
>>>>>>> Or do you mean you want to load an image file based on what the users
>>>>>>> select?
>>>>>>>
>>>>>>> Rick
>>>>>>>
>>>>>>>
>>>>>>> Bill wrote:
>>>>>>>
>>>>>>>
>>>>>>>              
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>>  I've gotten a request for one of my JSF applications for users to be
>>>>>>>> able to directly link to pages within the application.  The
>>>>>>>> application simply takes a bunch of form inputs and returns some
>>>>>>>> images derived from these inputs...it doesn't require any 'state'
>>>>>>>> information so it should be pretty straightforward.
>>>>>>>>
>>>>>>>>  Is there a way to do this without having to manually create a GET
>>>>>>>> type URL myself?  I start doing this, but it became apparent that
>>>>>>>> this
>>>>>>>> would be very tedious...
>>>>>>>>
>>>>>>>> -Bill
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                
>>>>>>>              

Re: Creating URLs referencing a JSF application

by Bill-124 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Okay, I also know how to construct the URL myself ;)

I know how to get the values the user has submitted.  I know how to
create a URL from it.  I also know how to read the parameters in from
the URL, process them, and give the user the page they want.

This to me, however, defeats the whole point of using JSF.  JSF should
do this for me, shouldn't it?  What's the point of JSF if I have to
get into the parameter parsing business?

On Fri, Jul 18, 2008 at 4:13 PM, Karthik <Karthikeyan.Rajeswaran@...> wrote:

>>
>> Does this make sense?
>
> It does. (And hopefully some one more knowledgeable will jump in...)
>
> Would getParameterMap() help in constructing the URL yourself?
>
> http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameterMap()
>
> thanks,
> karthik
>
> Bill wrote:
>>
>> I don't have a problem getting the query string.  The problem is that
>> JSF does not create a query string for a form submission so there is
>> no query string to get.
>>
>> As I posted in my earlier example, lets say I have 2 pulldowns "pd1"
>> and "pd2".  In "pd1" I select "optionA".  In "pd2" I select "optionB"
>> and submit the form.
>>
>> The application DOES NOT create a query string like
>> "?pd1=optionA&pd2=optionB".  If you look @ the URL @ the top of the
>> browser, there is no query string.  So there is no way that I know of
>> to allow a user to revisit that submitted form page via a bookmark or
>> direct link.  Instead, every time they want to go to the page where
>> pd1 = optionA and pd2 = optionB, they have to select the options in
>> the pulldowns and submit the page.
>>
>> I don't want them to have to do this!  I want to be able to give them
>> a link that does this form them.
>>
>> Does this make sense?
>>
>> On Fri, Jul 18, 2008 at 1:31 PM, Karthik <Karthikeyan.Rajeswaran@...>
>> wrote:
>>
>>>
>>>
>>> http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html#getQueryString()
>>>  Does it help?
>>>
>>> regards,
>>> karthik
>>>
>>> Bill wrote:
>>>
>>>>
>>>> Hi Karthik,
>>>>
>>>>  This is exactly my point...Can JSF construct this URL already or do
>>>> I have to do it manually and parse the arguments myself??
>>>>
>>>>  I started doing this manually, which is pretty easy for pulldowns
>>>> and the like, but what happens when the users suddenly have JSF
>>>> component Date fields to deal with?  JSF handles the input as a Date
>>>> class, so now I'd have to write a String to Date converter to convert
>>>> a date in a String argument to a Date class in my code.
>>>>
>>>>  I know this can be done...I just didn't want to have to do all this
>>>> manual work which JSF is supposed to eliminate!
>>>>
>>>> -Bill
>>>>
>>>> On Fri, Jul 18, 2008 at 1:18 PM, Karthik
>>>> <Karthikeyan.Rajeswaran@...>
>>>> wrote:
>>>>
>>>>
>>>>>
>>>>> I don't think i am understanding the question correctly; but , in
>>>>> page.jsp ,
>>>>> can you try
>>>>> 'response.sendRedirect("http://www.example.com?pd1=selection");
>>>>>
>>>>> Alternatively, you could have a 'Create URL' button on the page that
>>>>> can
>>>>> construct the url and show it to the user.
>>>>>
>>>>> Of course,  within a web application, one needs to be careful and
>>>>> ensure
>>>>> that a bookmarked page can be accessed independently. For instance, if
>>>>> the
>>>>> webapp requires a login, then when a user accesses a page directly with
>>>>> a
>>>>> set of parameters and has not logged in yet, the page should preferably
>>>>> show
>>>>> the login page to the user.
>>>>>
>>>>> regards,
>>>>> karthik
>>>>>
>>>>>
>>>>>
>>>>> Bill wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> Anyone have any ideas?  Am I not explaining this clearly?
>>>>>>
>>>>>> I would think linking into a JSF application, with arguments in the
>>>>>> URL, would be a pretty common usage...
>>>>>>
>>>>>> On Thu, Jul 17, 2008 at 9:44 PM, Bill <saxton@...> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Lets say you have 2 pulldowns, with id's "pd1" and "pd2" on a page
>>>>>>> "page.jsp" for your website "www.example.com".  If you create a form
>>>>>>> using these and submit then, there is no 'GET' type of url for them
>>>>>>> to
>>>>>>> bookmark, copy/paste.  You'd simply be on the same page:
>>>>>>>
>>>>>>> http://www.example.com/page.jsp
>>>>>>>
>>>>>>> So I'm looking for something that will automatically create this URL
>>>>>>> for me like:
>>>>>>>
>>>>>>> http://www.example.com/page.jsp?pd1=selection1&pd2=selection2
>>>>>>>
>>>>>>> On Thu, Jul 17, 2008 at 7:39 PM, Rick Fincher <rnf@...> wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Hi Bill,
>>>>>>>>
>>>>>>>> Do you mean you want to redirect to another pre-existing page as in:
>>>>>>>>
>>>>>>>>      try {
>>>>>>>>            ExternalContext externalContext =
>>>>>>>> getFacesContext().getExternalContext();
>>>>>>>>                          String pageURL =
>>>>>>>> externalContext.getRequestContextPath()  +"/faces/YourPage.jsp";
>>>>>>>>            externalContext.redirect(pageURL);
>>>>>>>>        } catch(IOException ioe) {
>>>>>>>>            ioe.printStackTrace(System.out);
>>>>>>>>            System.out.println(ioe.toString());
>>>>>>>>        }
>>>>>>>>
>>>>>>>> Or do you mean you want to load an image file based on what the
>>>>>>>> users
>>>>>>>> select?
>>>>>>>>
>>>>>>>> Rick
>>>>>>>>
>>>>>>>>
>>>>>>>> Bill wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Hi all,
>>>>>>>>>
>>>>>>>>>  I've gotten a request for one of my JSF applications for users to
>>>>>>>>> be
>>>>>>>>> able to directly link to pages within the application.  The
>>>>>>>>> application simply takes a bunch of form inputs and returns some
>>>>>>>>> images derived from these inputs...it doesn't require any 'state'
>>>>>>>>> information so it should be pretty straightforward.
>>>>>>>>>
>>>>>>>>>  Is there a way to do this without having to manually create a GET
>>>>>>>>> type URL myself?  I start doing this, but it became apparent that
>>>>>>>>> this
>>>>>>>>> would be very tedious...
>>>>>>>>>
>>>>>>>>> -Bill
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>

Re: Creating URLs referencing a JSF application

by William Korb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bill,

One of the drawbacks of JSF due to the built-in life cycle is that HTTP GETs are
not directly supported, since application state is stored in the life cycle. I
realize that your app does not need this state, but that doesn't matter, since
JSF forces you to use this.

If you need to use a GET, then you need some sort of intermediary servlet or
something that takes the passed parameters, drops them into the JSF session,
then redirects to the page that you want.

Good luck,
Bill

Bill wrote:
| Okay, I also know how to construct the URL myself ;)
|
| I know how to get the values the user has submitted.  I know how to
| create a URL from it.  I also know how to read the parameters in from
| the URL, process them, and give the user the page they want.
|
| This to me, however, defeats the whole point of using JSF.  JSF should
| do this for me, shouldn't it?  What's the point of JSF if I have to
| get into the parameter parsing business?
|
| On Fri, Jul 18, 2008 at 4:13 PM, Karthik <Karthikeyan.Rajeswaran@...> wrote:
|>> Does this make sense?
|> It does. (And hopefully some one more knowledgeable will jump in...)
|>
|> Would getParameterMap() help in constructing the URL yourself?
|>
|>
http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameterMap()
|>
|> thanks,
|> karthik
|>
|> Bill wrote:
|>> I don't have a problem getting the query string.  The problem is that
|>> JSF does not create a query string for a form submission so there is
|>> no query string to get.
|>>
|>> As I posted in my earlier example, lets say I have 2 pulldowns "pd1"
|>> and "pd2".  In "pd1" I select "optionA".  In "pd2" I select "optionB"
|>> and submit the form.
|>>
|>> The application DOES NOT create a query string like
|>> "?pd1=optionA&pd2=optionB".  If you look @ the URL @ the top of the
|>> browser, there is no query string.  So there is no way that I know of
|>> to allow a user to revisit that submitted form page via a bookmark or
|>> direct link.  Instead, every time they want to go to the page where
|>> pd1 = optionA and pd2 = optionB, they have to select the options in
|>> the pulldowns and submit the page.
|>>
|>> I don't want them to have to do this!  I want to be able to give them
|>> a link that does this form them.
|>>
|>> Does this make sense?
|>>
|>> On Fri, Jul 18, 2008 at 1:31 PM, Karthik <Karthikeyan.Rajeswaran@...>
|>> wrote:
|>>
|>>>
|>>>
http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html#getQueryString()
|>>>  Does it help?
|>>>
|>>> regards,
|>>> karthik
|>>>
|>>> Bill wrote:
|>>>
|>>>> Hi Karthik,
|>>>>
|>>>>  This is exactly my point...Can JSF construct this URL already or do
|>>>> I have to do it manually and parse the arguments myself??
|>>>>
|>>>>  I started doing this manually, which is pretty easy for pulldowns
|>>>> and the like, but what happens when the users suddenly have JSF
|>>>> component Date fields to deal with?  JSF handles the input as a Date
|>>>> class, so now I'd have to write a String to Date converter to convert
|>>>> a date in a String argument to a Date class in my code.
|>>>>
|>>>>  I know this can be done...I just didn't want to have to do all this
|>>>> manual work which JSF is supposed to eliminate!
|>>>>
|>>>> -Bill
|>>>>
|>>>> On Fri, Jul 18, 2008 at 1:18 PM, Karthik
|>>>> <Karthikeyan.Rajeswaran@...>
|>>>> wrote:
|>>>>
|>>>>
|>>>>> I don't think i am understanding the question correctly; but , in
|>>>>> page.jsp ,
|>>>>> can you try
|>>>>> 'response.sendRedirect("http://www.example.com?pd1=selection");
|>>>>>
|>>>>> Alternatively, you could have a 'Create URL' button on the page that
|>>>>> can
|>>>>> construct the url and show it to the user.
|>>>>>
|>>>>> Of course,  within a web application, one needs to be careful and
|>>>>> ensure
|>>>>> that a bookmarked page can be accessed independently. For instance, if
|>>>>> the
|>>>>> webapp requires a login, then when a user accesses a page directly with
|>>>>> a
|>>>>> set of parameters and has not logged in yet, the page should preferably
|>>>>> show
|>>>>> the login page to the user.
|>>>>>
|>>>>> regards,
|>>>>> karthik
|>>>>>
|>>>>>
|>>>>>
|>>>>> Bill wrote:
|>>>>>
|>>>>>
|>>>>>> Anyone have any ideas?  Am I not explaining this clearly?
|>>>>>>
|>>>>>> I would think linking into a JSF application, with arguments in the
|>>>>>> URL, would be a pretty common usage...
|>>>>>>
|>>>>>> On Thu, Jul 17, 2008 at 9:44 PM, Bill <saxton@...> wrote:
|>>>>>>
|>>>>>>
|>>>>>>
|>>>>>>> Lets say you have 2 pulldowns, with id's "pd1" and "pd2" on a page
|>>>>>>> "page.jsp" for your website "www.example.com".  If you create a form
|>>>>>>> using these and submit then, there is no 'GET' type of url for them
|>>>>>>> to
|>>>>>>> bookmark, copy/paste.  You'd simply be on the same page:
|>>>>>>>
|>>>>>>> http://www.example.com/page.jsp
|>>>>>>>
|>>>>>>> So I'm looking for something that will automatically create this URL
|>>>>>>> for me like:
|>>>>>>>
|>>>>>>> http://www.example.com/page.jsp?pd1=selection1&pd2=selection2
|>>>>>>>
|>>>>>>> On Thu, Jul 17, 2008 at 7:39 PM, Rick Fincher <rnf@...> wrote:
|>>>>>>>
|>>>>>>>
|>>>>>>>
|>>>>>>>> Hi Bill,
|>>>>>>>>
|>>>>>>>> Do you mean you want to redirect to another pre-existing page as in:
|>>>>>>>>
|>>>>>>>>      try {
|>>>>>>>>            ExternalContext externalContext =
|>>>>>>>> getFacesContext().getExternalContext();
|>>>>>>>>                          String pageURL =
|>>>>>>>> externalContext.getRequestContextPath()  +"/faces/YourPage.jsp";
|>>>>>>>>            externalContext.redirect(pageURL);
|>>>>>>>>        } catch(IOException ioe) {
|>>>>>>>>            ioe.printStackTrace(System.out);
|>>>>>>>>            System.out.println(ioe.toString());
|>>>>>>>>        }
|>>>>>>>>
|>>>>>>>> Or do you mean you want to load an image file based on what the
|>>>>>>>> users
|>>>>>>>> select?
|>>>>>>>>
|>>>>>>>> Rick
|>>>>>>>>
|>>>>>>>>
|>>>>>>>> Bill wrote:
|>>>>>>>>
|>>>>>>>>
|>>>>>>>>
|>>>>>>>>> Hi all,
|>>>>>>>>>
|>>>>>>>>>  I've gotten a request for one of my JSF applications for users to
|>>>>>>>>> be
|>>>>>>>>> able to directly link to pages within the application.  The
|>>>>>>>>> application simply takes a bunch of form inputs and returns some
|>>>>>>>>> images derived from these inputs...it doesn't require any 'state'
|>>>>>>>>> information so it should be pretty straightforward.
|>>>>>>>>>
|>>>>>>>>>  Is there a way to do this without having to manually create a GET
|>>>>>>>>> type URL myself?  I start doing this, but it became apparent that
|>>>>>>>>> this
|>>>>>>>>> would be very tedious...
|>>>>>>>>>
|>>>>>>>>> -Bill
|>>>>>>>>>
|>>>>>>>>>
|>>>>>>>>>
|>>>>>>>>>
|>>>>>>>>

- --
William Korb, President & CTO          Phone:  715-382-5462
QISC, Inc.                             Fax:    715-382-5462
19945 82nd Ave., Suite 201             E-mail: korb@...
Chippewa Falls, WI 54729-5631          URL:    http://www.qisc.com/
"Tilting at Digital Windmills since 1995.&