You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Matthew J. Vincent" <vi...@cs.usm.maine.edu> on 2004/01/23 20:20:33 UTC

Struts Search/Results/Display Help (includes link to Example to help me with)

http:// www ! moosejaw ! org /java/help.zip

Here is a zip file to demonstrate the problem I am having.  I just hacked
this together, but it shows what I have been talking about.

1. Unzip this and put the helpv1.war in your webapps folder
2. Start servlet container
3. Goto http://localhost:8888/helpv1

This should take you to index.do which is fine.  Click "Search" which takes
you top search.do.  Type "1" for the Item Id and select "Lable 2" for the
Utem Type and click "Search".  Do you see how the values are lost?  How can
I mantain those values?  Should I just have 1 Action class that handles both
the search form and the search results?  If so, how do I set this up?

Thanks for your help!

Matt



-----Original Message-----
From: Hubert Rabago [mailto:jakartauser@yahoo.com]
Sent: Friday, January 23, 2004 11:31 AM
To: Struts Users Mailing List
Subject: Re: Strust Search/Results/Display HELP!


For your steps 2 to 4:

in your struts-config:

<form-bean name="myForm" type="com.my.form.MyForm"/>
...
<action path="/pageWithForm" type="com.my.action.PreparePageAction">
    <forward name="showForm" path="/form.jsp">
</action>
<action path="/formDestination"
    type="com.my.action.PreparePageAction"
    name="myForm"
    input="/form.jsp">
    ...  <!-- show page for step 4 -->
</action>


in your jsp:
<html:form action="/formDestination">
    <html:text property="someMyFormProperty"/>
    <html:text property="otherMyFormProperty"/>
    <html:submit/>
</html:form>
<%-- also use the struts tags to display error messages --%>


In your case, you may need to use input="/pageWithForm.do" since you need to
prep
the form, but there are other ways to do that, like placing your <SELECT>'s
options collection in session or app scope.  However, I *have* used this
approach
before and it worked for me.

hth,
Hubert

--- "Matthew J. Vincent" <vi...@cs.usm.maine.edu> wrote:
> Ok.  I guess I'm missing something - or it just won't sink in.  This
really
> isn't that long.
>
> For simplicity, let's say I have a 4 page application.
>
> 1. Index
> 2. Search for an Item
> 3. Search Results List of Matching items
> 4. Details of an Item
>
> All of these "pages" needs to gather data from a database (not the
problem)
> and display to them to the end user.
>
> A typical scenario for a user would be:
>
> 1. User goes to http://localhost:8888/protoype they will land on the index
> page that really needs to be an Action because it looks up data from the
> database.
> 2. They click search which also gathers data from the database to display
a
> form.
> 3. They fill the form in and click Search.
> 4. They see the matching search results.
> 5. They pick the matching search result and the Item is displayed.
>
> Each page is essentially an action that forwards it's results to a jsp
page.
>
> However, here is the problem I am having.  When an error occurs, I need to
> have that error displayed to the end user and have them on the previous
> page.
>
> For example, Step 2 to Step 3 from above - if the user does not type in a
> required field or there are no results, they need to be told this and
placed
> back on Step 2 with:
> 1. the form values filled out with what they submitted
> 2. this page needs to gather the data from the database again (in case
more
> data has been added).
>
> So I'm not sure of:
>
> 1. What do I need to put in the struts-config.xml file (specifically in
the
> Action Mappings section)
>
>       <action path="/search"
>               type="SearchAction">
>          <forward name="success" path="/search.jsp"/>
>          <forward name="failure" path="/appError.jsp"/>
>       </action>
>       <action path = "/searchResults"
>               type = "SearchResultsAction"
>               name = "strainSearchForm"
>               validate = "true"  <---------- I know will call the validate
> method
>               input = "/search.do"> <---------- can this be an Action?
>          <forward name="success" path="/searchResults.jsp"/>
>          <forward name="failure" path="/search.do"/>  <---------- If this
is
> search.jsp, the data from the database is not regathered
>          <forward name="error" path="/appError.jsp"/>
>       </action>
>
>
> 2. Should I have 1 action or is having multiple actions ok?  If just 1
> action, how do I set this up?
>
> 3. What is the best approach for this type of scenario?  I can solve this
> fine with a straight Servlet and JSP approach, but what is the "Struts
way"?
>
> Hubert and Wendy have answered my questions, but I am recovering from a
cold
> and nothing is getting into my brain.
>
> Thanks for the help.  Be gentle and explain slowly.  :)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: JSP to static html...

Posted by Jacob Wilson <st...@yahoo.com>.
Actually, this is therequirement... One jsp page(contains scriptlets, dynamic values. etal) in the current application generates a report. Now, I need to present with a button at the end of the page.
 
When I click on that button, this page should be converted into a static html and then 
ftp this html page to one of the servers...
 
I know uploading could be done without probs... But, the only question I have is how do I convert that page into an html???

David Erickson <de...@cmcflex.com> wrote:
I don't know the layouts of your jsps or what you are doing in them.. but
JSP's are inherently non-static because they use runtime expressions to
generate the html, and that can change on a per request basis. If you are
using strictly html and no RT expressions or tags or anything I don't see
why you couldnt just rename the extension from jsp to html and save it
wherever you want.
-David

----- Original Message ----- 
From: "Jacob Wilson" 
To: "Struts Users Mailing List" 
Sent: Friday, January 23, 2004 12:30 PM
Subject: JSP to static html...


> Hi All...
>
> I have a specific requirement in my project... I want to convert the JSP
pages to static html pages and save them in a local directory... How do I
achieve this functionality??? Any suggestions appreciated.
>
> Thanks much.
>
> -Jacob
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

RE: JSP to static html...

Posted by Wiebe de Jong <wi...@shaw.ca>.
David,

I have had this situation come up before and it is quite valid.

I once wrote a catalog web app for a client with only a couple of templates
but hundreds of items in the database. They wanted a static cdrom version of
the catalog for customers so I used a tool (can't remember the name now but
it started with an 'x') to spider through the site, make an html copy of all
the pages, and fix the links appropriately.

The only tools I can think of now are: 
Zylox: http://www.zylox.com/tasks/dynamic2static.shtm 
Teleport Pro: http://www.tenmax.com/teleport/pro/home.htm 

Wiebe

-----Original Message-----
From: David Erickson [mailto:derickson@cmcflex.com] 
Sent: Friday, January 23, 2004 2:14 PM
To: Struts Users Mailing List
Subject: Re: JSP to static html...

I don't know the layouts of your jsps or what you are doing in them.. but
JSP's are inherently non-static because they use runtime expressions to
generate the html, and that can change on a per request basis.  If you are
using strictly html and no RT expressions or tags or anything I don't see
why you couldnt just rename the extension from jsp to html and save it
wherever you want.
-David

----- Original Message ----- 
From: "Jacob Wilson" <st...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, January 23, 2004 12:30 PM
Subject: JSP to static html...


> Hi All...
>
> I have a specific requirement in my project... I want to convert the JSP
pages to static html pages and save them in a local directory... How do I
achieve this functionality??? Any suggestions appreciated.
>
> Thanks much.
>
> -Jacob
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: JSP to static html...

Posted by David Erickson <de...@cmcflex.com>.
I don't know the layouts of your jsps or what you are doing in them.. but
JSP's are inherently non-static because they use runtime expressions to
generate the html, and that can change on a per request basis.  If you are
using strictly html and no RT expressions or tags or anything I don't see
why you couldnt just rename the extension from jsp to html and save it
wherever you want.
-David

----- Original Message ----- 
From: "Jacob Wilson" <st...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, January 23, 2004 12:30 PM
Subject: JSP to static html...


> Hi All...
>
> I have a specific requirement in my project... I want to convert the JSP
pages to static html pages and save them in a local directory... How do I
achieve this functionality??? Any suggestions appreciated.
>
> Thanks much.
>
> -Jacob
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: JSP to static html...

Posted by Max Cooper <ma...@maxcooper.com>.
Jacob,

It sounds like your requirements preclude doing this at build time. I assume
having the button to ftp a static HTML version of the report to a server
somewhere means that the report has some parameters to customize the report,
or at least that the report should be run at the time the user clicks the
button (even if there is no configuration of the report itself).

In that case, it seems like you could have the server make a request to
itself and then save the response (HTML generated by executing the JSP) in a
file or just stream it directly to the ftp server that is waiting to receive
it. I don't have any magic tips about converting JSP to HTML -- I would just
let the server execute the JSP to convert it to HTML. If you need to strip
things out (JavaScript, etc.) you may need to create a new JSP or manipulate
the response to remove that stuff.

-Max

----- Original Message ----- 
From: "Jacob Wilson" <st...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, January 23, 2004 3:58 PM
Subject: Re: JSP to static html...


>
> Thanks Max. This sounds very good. Your saying that automatically creating
an html when the jsp is rendered sounds good. This should solve my problem.
We are using websphere 5.0.  We are not using ant though...
>
> If you can give me little more details on the configuration stuff and how
to specify a particular jsp to be converted into an html, that would be
great...
>
> -Jacob
>
> Max Cooper <ma...@maxcooper.com> wrote:
> View Source ... Save As works generally, but browsers sometimes mess with
> the HTML in subtle ways (netscape used to add an HTML tag, for
> instance), so I would be very wary of using that technique (diff users
> w/diff browser, changes after browser upgrade, etc.). The command-line
tools
> curl or wget should be more trustworthy to deliver the HTML as delivered
by
> the server with no molestation.
>
> If you want to automate the process (which I highly recommend if you are
> really going to do this), you could use Ant to deploy your app and its
JSPs
> on a server and then make requests for all of the pages, saving the
> responses as build output.
>
> Before doing any of this, I would take a detailed look at why you want to
> render your JSPs and convert them to HTML. It seems likely that there is a
> better (easier) way to achieve the intended goal. Ant and its various
> filtering, token-replacing and other abilities may offer a more manageable
> solution.
>
> -Max
>
> ----- Original Message ----- 
> From: "Ron Day"
> To: "Struts Users Mailing List"
> Sent: Friday, January 23, 2004 2:28 PM
> Subject: RE: JSP to static html...
>
>
> > View source in browser and save it to xxx.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: JSP to static html...

Posted by Jacob Wilson <st...@yahoo.com>.
Thanks Max. This sounds very good. Your saying that automatically creating an html when the jsp is rendered sounds good. This should solve my problem. We are using websphere 5.0.  We are not using ant though...
 
If you can give me little more details on the configuration stuff and how to specify a particular jsp to be converted into an html, that would be great...
 
-Jacob

Max Cooper <ma...@maxcooper.com> wrote:
View Source ... Save As works generally, but browsers sometimes mess with
the HTML in subtle ways (netscape used to add an HTML tag, for
instance), so I would be very wary of using that technique (diff users
w/diff browser, changes after browser upgrade, etc.). The command-line tools
curl or wget should be more trustworthy to deliver the HTML as delivered by
the server with no molestation.

If you want to automate the process (which I highly recommend if you are
really going to do this), you could use Ant to deploy your app and its JSPs
on a server and then make requests for all of the pages, saving the
responses as build output.

Before doing any of this, I would take a detailed look at why you want to
render your JSPs and convert them to HTML. It seems likely that there is a
better (easier) way to achieve the intended goal. Ant and its various
filtering, token-replacing and other abilities may offer a more manageable
solution.

-Max

----- Original Message ----- 
From: "Ron Day" 
To: "Struts Users Mailing List" 
Sent: Friday, January 23, 2004 2:28 PM
Subject: RE: JSP to static html...


> View source in browser and save it to xxx.html


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

Re: JSP to static html...

Posted by Max Cooper <ma...@maxcooper.com>.
View Source ... Save As works generally, but browsers sometimes mess with
the HTML in subtle ways (netscape used to add an HTML <base> tag, for
instance), so I would be very wary of using that technique (diff users
w/diff browser, changes after browser upgrade, etc.). The command-line tools
curl or wget should be more trustworthy to deliver the HTML as delivered by
the server with no molestation.

If you want to automate the process (which I highly recommend if you are
really going to do this), you could use Ant to deploy your app and its JSPs
on a server and then make requests for all of the pages, saving the
responses as build output.

Before doing any of this, I would take a detailed look at why you want to
render your JSPs and convert them to HTML. It seems likely that there is a
better (easier) way to achieve the intended goal. Ant and its various
filtering, token-replacing and other abilities may offer a more manageable
solution.

-Max

----- Original Message ----- 
From: "Ron Day" <ro...@ronday.cc>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, January 23, 2004 2:28 PM
Subject: RE: JSP to static html...


> View source in browser and save it to xxx.html


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: JSP to static html...

Posted by Mark Lowe <ma...@talk21.com>.
wget or curl


On 23 Jan 2004, at 22:28, Ron Day wrote:

> View source in browser and save it to xxx.html
>
> -----Original Message-----
> From: Jacob Wilson [mailto:strutsjo@yahoo.com]
> Sent: Friday, January 23, 2004 1:31 PM
> To: Struts Users Mailing List
> Subject: JSP to static html...
>
>
> Hi All...
>
> I have a specific requirement in my project... I want to convert the 
> JSP
> pages to static html pages and save them in a local directory... How 
> do I
> achieve this functionality??? Any suggestions appreciated.
>
> Thanks much.
>
> -Jacob
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: JSP to static html...

Posted by Ron Day <ro...@ronday.cc>.
View source in browser and save it to xxx.html

-----Original Message-----
From: Jacob Wilson [mailto:strutsjo@yahoo.com]
Sent: Friday, January 23, 2004 1:31 PM
To: Struts Users Mailing List
Subject: JSP to static html...


Hi All...

I have a specific requirement in my project... I want to convert the JSP
pages to static html pages and save them in a local directory... How do I
achieve this functionality??? Any suggestions appreciated.

Thanks much.

-Jacob


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


JSP to static html...

Posted by Jacob Wilson <st...@yahoo.com>.
Hi All...
 
I have a specific requirement in my project... I want to convert the JSP pages to static html pages and save them in a local directory... How do I achieve this functionality??? Any suggestions appreciated.
 
Thanks much.
 
-Jacob


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

RE: Struts Search/Results/Display Help (includes link to Example to help me with)

Posted by Hubert Rabago <ja...@yahoo.com>.
Actually, "session" is the default scope.  What you want is to set the scope to
"request".

--- "Matthew J. Vincent" <vi...@cs.usm.maine.edu> wrote:
> Hubert...thanks!
> 
> Now, how do I then clear the fields out if the want to do a new search?
> Currently, the user types in http://localhost:8888/helpv1/search.do , the
> values that they filled in are still there.  I only want those values to
> "persist" if there is an error of some sort...otherwise reset back to
> original.  Another way to think of it is when the user links to the search
> page it should be "fresh", but on error it is "dirty".  I tried changing the
> scope to session, but that didn't help.  Is there a trick to the reset
> method in the form that I should use?
> 
> Matt
> 
> 
> -----Original Message-----
> From: Hubert Rabago [mailto:jakartauser@yahoo.com]
> Sent: Friday, January 23, 2004 2:52 PM
> To: Struts Users Mailing List
> Subject: Re: Struts Search/Results/Display Help (includes link to
> Example to help me with)
> 
> 
> Like in my two previous emails, it worked when I took out the "name" and
> "type"
> attributes in your html form:
> 
> <%--
> <html-el:form action="searchResults"
>            name="itemSearch"
>            type="SearchForm">
> --%>
> <html-el:form action="searchResults">
> 
> hth,
> Hubert
> 
> --- "Matthew J. Vincent" <vi...@cs.usm.maine.edu> wrote:
> > http:// www ! moosejaw ! org /java/help.zip
> >
> > Here is a zip file to demonstrate the problem I am having.  I just hacked
> > this together, but it shows what I have been talking about.
> >
> > 1. Unzip this and put the helpv1.war in your webapps folder
> > 2. Start servlet container
> > 3. Goto http://localhost:8888/helpv1
> >
> > This should take you to index.do which is fine.  Click "Search" which
> takes
> > you top search.do.  Type "1" for the Item Id and select "Lable 2" for the
> > Utem Type and click "Search".  Do you see how the values are lost?  How
> can
> > I mantain those values?  Should I just have 1 Action class that handles
> both
> > the search form and the search results?  If so, how do I set this up?
> >
> > Thanks for your help!
> >
> > Matt
> >
> >
> >
> > -----Original Message-----
> > From: Hubert Rabago [mailto:jakartauser@yahoo.com]
> > Sent: Friday, January 23, 2004 11:31 AM
> > To: Struts Users Mailing List
> > Subject: Re: Strust Search/Results/Display HELP!
> >
> >
> > For your steps 2 to 4:
> >
> > in your struts-config:
> >
> > <form-bean name="myForm" type="com.my.form.MyForm"/>
> > ...
> > <action path="/pageWithForm" type="com.my.action.PreparePageAction">
> >     <forward name="showForm" path="/form.jsp">
> > </action>
> > <action path="/formDestination"
> >     type="com.my.action.PreparePageAction"
> >     name="myForm"
> >     input="/form.jsp">
> >     ...  <!-- show page for step 4 -->
> > </action>
> >
> >
> > in your jsp:
> > <html:form action="/formDestination">
> >     <html:text property="someMyFormProperty"/>
> >     <html:text property="otherMyFormProperty"/>
> >     <html:submit/>
> > </html:form>
> > <%-- also use the struts tags to display error messages --%>
> >
> >
> > In your case, you may need to use input="/pageWithForm.do" since you need
> to
> > prep
> > the form, but there are other ways to do that, like placing your
> <SELECT>'s
> > options collection in session or app scope.  However, I *have* used this
> > approach
> > before and it worked for me.
> >
> > hth,
> > Hubert
> >
> > --- "Matthew J. Vincent" <vi...@cs.usm.maine.edu> wrote:
> > > Ok.  I guess I'm missing something - or it just won't sink in.  This
> > really
> > > isn't that long.
> > >
> > > For simplicity, let's say I have a 4 page application.
> > >
> > > 1. Index
> > > 2. Search for an Item
> > > 3. Search Results List of Matching items
> > > 4. Details of an Item
> > >
> > > All of these "pages" needs to gather data from a database (not the
> > problem)
> > > and display to them to the end user.
> > >
> > > A typical scenario for a user would be:
> > >
> > > 1. User goes to http://localhost:8888/protoype they will land on the
> index
> > > page that really needs to be an Action because it looks up data from the
> > > database.
> > > 2. They click search which also gathers data from the database to
> display
> > a
> > > form.
> > > 3. They fill the form in and click Search.
> > > 4. They see the matching search results.
> > > 5. They pick the matching search result and the Item is displayed.
> > >
> > > Each page is essentially an action that forwards it's results to a jsp
> > page.
> > >
> > > However, here is the problem I am having.  When an error occurs, I need
> to
> > > have that error displayed to the end user and have them on the previous
> > > page.
> > >
> > > For example, Step 2 to Step 3 from above - if the user does not type in
> a
> > > required field or there are no results, they need to be told this and
> > placed
> > > back on Step 2 with:
> > > 1. the form values filled out with what they submitted
> > > 2. this page needs to gather the data from the database again (in case
> > more
> > > data has been added).
> > >
> > > So I'm not sure of:
> > >
> > > 1. What do I need to put in the struts-config.xml file (specifically in
> > the
> > > Action Mappings section)
> > >
> > >       <action path="/search"
> > >               type="SearchAction">
> > >          <forward name="success" path="/search.jsp"/>
> > >          <forward name="failure" path="/appError.jsp"/>
> > >       </action>
> > >       <action path = "/searchResults"
> > >               type = "SearchResultsAction"
> > >               name = "strainSearchForm"
> > >               validate = "true"  <---------- I know will call the
> validate
> > > method
> > >               input = "/search.do"> <---------- can this be an Action?
> > >          <forward name="success" path="/searchResults.jsp"/>
> > >          <forward name="failure" path="/search.do"/>  <---------- If
> this
> > is
> > > search.jsp, the data from the database is not regathered
> > >          <forward name="error" path="/appError.jsp"/>
> > >       </action>
> > >
> > >
> > > 2. Should I have 1 action or is having multiple actions ok?  If just 1
> > > action, how do I set this up?
> > >
> > > 3. What is the best approach for this type of scenario?  I can solve
> this
> > > fine with a straight Servlet and JSP approach, but what is the "Struts
> > way"?
> > >
> > > Hubert and Wendy have answered my questions, but I am recovering from a
> > cold
> > > and nothing is getting into my brain.
> > >
> > > Thanks for the help.  Be gentle and explain slowly.  :)
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >
> >
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Struts Search/Results/Display Help (includes link to Example to help me with)

Posted by "Matthew J. Vincent" <vi...@cs.usm.maine.edu>.
Hubert...thanks!

Now, how do I then clear the fields out if the want to do a new search?
Currently, the user types in http://localhost:8888/helpv1/search.do , the
values that they filled in are still there.  I only want those values to
"persist" if there is an error of some sort...otherwise reset back to
original.  Another way to think of it is when the user links to the search
page it should be "fresh", but on error it is "dirty".  I tried changing the
scope to session, but that didn't help.  Is there a trick to the reset
method in the form that I should use?

Matt


-----Original Message-----
From: Hubert Rabago [mailto:jakartauser@yahoo.com]
Sent: Friday, January 23, 2004 2:52 PM
To: Struts Users Mailing List
Subject: Re: Struts Search/Results/Display Help (includes link to
Example to help me with)


Like in my two previous emails, it worked when I took out the "name" and
"type"
attributes in your html form:

<%--
<html-el:form action="searchResults"
           name="itemSearch"
           type="SearchForm">
--%>
<html-el:form action="searchResults">

hth,
Hubert

--- "Matthew J. Vincent" <vi...@cs.usm.maine.edu> wrote:
> http:// www ! moosejaw ! org /java/help.zip
>
> Here is a zip file to demonstrate the problem I am having.  I just hacked
> this together, but it shows what I have been talking about.
>
> 1. Unzip this and put the helpv1.war in your webapps folder
> 2. Start servlet container
> 3. Goto http://localhost:8888/helpv1
>
> This should take you to index.do which is fine.  Click "Search" which
takes
> you top search.do.  Type "1" for the Item Id and select "Lable 2" for the
> Utem Type and click "Search".  Do you see how the values are lost?  How
can
> I mantain those values?  Should I just have 1 Action class that handles
both
> the search form and the search results?  If so, how do I set this up?
>
> Thanks for your help!
>
> Matt
>
>
>
> -----Original Message-----
> From: Hubert Rabago [mailto:jakartauser@yahoo.com]
> Sent: Friday, January 23, 2004 11:31 AM
> To: Struts Users Mailing List
> Subject: Re: Strust Search/Results/Display HELP!
>
>
> For your steps 2 to 4:
>
> in your struts-config:
>
> <form-bean name="myForm" type="com.my.form.MyForm"/>
> ...
> <action path="/pageWithForm" type="com.my.action.PreparePageAction">
>     <forward name="showForm" path="/form.jsp">
> </action>
> <action path="/formDestination"
>     type="com.my.action.PreparePageAction"
>     name="myForm"
>     input="/form.jsp">
>     ...  <!-- show page for step 4 -->
> </action>
>
>
> in your jsp:
> <html:form action="/formDestination">
>     <html:text property="someMyFormProperty"/>
>     <html:text property="otherMyFormProperty"/>
>     <html:submit/>
> </html:form>
> <%-- also use the struts tags to display error messages --%>
>
>
> In your case, you may need to use input="/pageWithForm.do" since you need
to
> prep
> the form, but there are other ways to do that, like placing your
<SELECT>'s
> options collection in session or app scope.  However, I *have* used this
> approach
> before and it worked for me.
>
> hth,
> Hubert
>
> --- "Matthew J. Vincent" <vi...@cs.usm.maine.edu> wrote:
> > Ok.  I guess I'm missing something - or it just won't sink in.  This
> really
> > isn't that long.
> >
> > For simplicity, let's say I have a 4 page application.
> >
> > 1. Index
> > 2. Search for an Item
> > 3. Search Results List of Matching items
> > 4. Details of an Item
> >
> > All of these "pages" needs to gather data from a database (not the
> problem)
> > and display to them to the end user.
> >
> > A typical scenario for a user would be:
> >
> > 1. User goes to http://localhost:8888/protoype they will land on the
index
> > page that really needs to be an Action because it looks up data from the
> > database.
> > 2. They click search which also gathers data from the database to
display
> a
> > form.
> > 3. They fill the form in and click Search.
> > 4. They see the matching search results.
> > 5. They pick the matching search result and the Item is displayed.
> >
> > Each page is essentially an action that forwards it's results to a jsp
> page.
> >
> > However, here is the problem I am having.  When an error occurs, I need
to
> > have that error displayed to the end user and have them on the previous
> > page.
> >
> > For example, Step 2 to Step 3 from above - if the user does not type in
a
> > required field or there are no results, they need to be told this and
> placed
> > back on Step 2 with:
> > 1. the form values filled out with what they submitted
> > 2. this page needs to gather the data from the database again (in case
> more
> > data has been added).
> >
> > So I'm not sure of:
> >
> > 1. What do I need to put in the struts-config.xml file (specifically in
> the
> > Action Mappings section)
> >
> >       <action path="/search"
> >               type="SearchAction">
> >          <forward name="success" path="/search.jsp"/>
> >          <forward name="failure" path="/appError.jsp"/>
> >       </action>
> >       <action path = "/searchResults"
> >               type = "SearchResultsAction"
> >               name = "strainSearchForm"
> >               validate = "true"  <---------- I know will call the
validate
> > method
> >               input = "/search.do"> <---------- can this be an Action?
> >          <forward name="success" path="/searchResults.jsp"/>
> >          <forward name="failure" path="/search.do"/>  <---------- If
this
> is
> > search.jsp, the data from the database is not regathered
> >          <forward name="error" path="/appError.jsp"/>
> >       </action>
> >
> >
> > 2. Should I have 1 action or is having multiple actions ok?  If just 1
> > action, how do I set this up?
> >
> > 3. What is the best approach for this type of scenario?  I can solve
this
> > fine with a straight Servlet and JSP approach, but what is the "Struts
> way"?
> >
> > Hubert and Wendy have answered my questions, but I am recovering from a
> cold
> > and nothing is getting into my brain.
> >
> > Thanks for the help.  Be gentle and explain slowly.  :)
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!
> http://webhosting.yahoo.com/ps/sb/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Struts Search/Results/Display Help (includes link to Example to help me with)

Posted by Hubert Rabago <ja...@yahoo.com>.
Like in my two previous emails, it worked when I took out the "name" and "type"
attributes in your html form:

<%--
<html-el:form action="searchResults"
           name="itemSearch"
           type="SearchForm">
--%>
<html-el:form action="searchResults">

hth,
Hubert

--- "Matthew J. Vincent" <vi...@cs.usm.maine.edu> wrote:
> http:// www ! moosejaw ! org /java/help.zip
> 
> Here is a zip file to demonstrate the problem I am having.  I just hacked
> this together, but it shows what I have been talking about.
> 
> 1. Unzip this and put the helpv1.war in your webapps folder
> 2. Start servlet container
> 3. Goto http://localhost:8888/helpv1
> 
> This should take you to index.do which is fine.  Click "Search" which takes
> you top search.do.  Type "1" for the Item Id and select "Lable 2" for the
> Utem Type and click "Search".  Do you see how the values are lost?  How can
> I mantain those values?  Should I just have 1 Action class that handles both
> the search form and the search results?  If so, how do I set this up?
> 
> Thanks for your help!
> 
> Matt
> 
> 
> 
> -----Original Message-----
> From: Hubert Rabago [mailto:jakartauser@yahoo.com]
> Sent: Friday, January 23, 2004 11:31 AM
> To: Struts Users Mailing List
> Subject: Re: Strust Search/Results/Display HELP!
> 
> 
> For your steps 2 to 4:
> 
> in your struts-config:
> 
> <form-bean name="myForm" type="com.my.form.MyForm"/>
> ...
> <action path="/pageWithForm" type="com.my.action.PreparePageAction">
>     <forward name="showForm" path="/form.jsp">
> </action>
> <action path="/formDestination"
>     type="com.my.action.PreparePageAction"
>     name="myForm"
>     input="/form.jsp">
>     ...  <!-- show page for step 4 -->
> </action>
> 
> 
> in your jsp:
> <html:form action="/formDestination">
>     <html:text property="someMyFormProperty"/>
>     <html:text property="otherMyFormProperty"/>
>     <html:submit/>
> </html:form>
> <%-- also use the struts tags to display error messages --%>
> 
> 
> In your case, you may need to use input="/pageWithForm.do" since you need to
> prep
> the form, but there are other ways to do that, like placing your <SELECT>'s
> options collection in session or app scope.  However, I *have* used this
> approach
> before and it worked for me.
> 
> hth,
> Hubert
> 
> --- "Matthew J. Vincent" <vi...@cs.usm.maine.edu> wrote:
> > Ok.  I guess I'm missing something - or it just won't sink in.  This
> really
> > isn't that long.
> >
> > For simplicity, let's say I have a 4 page application.
> >
> > 1. Index
> > 2. Search for an Item
> > 3. Search Results List of Matching items
> > 4. Details of an Item
> >
> > All of these "pages" needs to gather data from a database (not the
> problem)
> > and display to them to the end user.
> >
> > A typical scenario for a user would be:
> >
> > 1. User goes to http://localhost:8888/protoype they will land on the index
> > page that really needs to be an Action because it looks up data from the
> > database.
> > 2. They click search which also gathers data from the database to display
> a
> > form.
> > 3. They fill the form in and click Search.
> > 4. They see the matching search results.
> > 5. They pick the matching search result and the Item is displayed.
> >
> > Each page is essentially an action that forwards it's results to a jsp
> page.
> >
> > However, here is the problem I am having.  When an error occurs, I need to
> > have that error displayed to the end user and have them on the previous
> > page.
> >
> > For example, Step 2 to Step 3 from above - if the user does not type in a
> > required field or there are no results, they need to be told this and
> placed
> > back on Step 2 with:
> > 1. the form values filled out with what they submitted
> > 2. this page needs to gather the data from the database again (in case
> more
> > data has been added).
> >
> > So I'm not sure of:
> >
> > 1. What do I need to put in the struts-config.xml file (specifically in
> the
> > Action Mappings section)
> >
> >       <action path="/search"
> >               type="SearchAction">
> >          <forward name="success" path="/search.jsp"/>
> >          <forward name="failure" path="/appError.jsp"/>
> >       </action>
> >       <action path = "/searchResults"
> >               type = "SearchResultsAction"
> >               name = "strainSearchForm"
> >               validate = "true"  <---------- I know will call the validate
> > method
> >               input = "/search.do"> <---------- can this be an Action?
> >          <forward name="success" path="/searchResults.jsp"/>
> >          <forward name="failure" path="/search.do"/>  <---------- If this
> is
> > search.jsp, the data from the database is not regathered
> >          <forward name="error" path="/appError.jsp"/>
> >       </action>
> >
> >
> > 2. Should I have 1 action or is having multiple actions ok?  If just 1
> > action, how do I set this up?
> >
> > 3. What is the best approach for this type of scenario?  I can solve this
> > fine with a straight Servlet and JSP approach, but what is the "Struts
> way"?
> >
> > Hubert and Wendy have answered my questions, but I am recovering from a
> cold
> > and nothing is getting into my brain.
> >
> > Thanks for the help.  Be gentle and explain slowly.  :)
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!
> http://webhosting.yahoo.com/ps/sb/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org