Hello,

I'm having trouble doing what I want with a struts;
I've read through the documentation and examples but
haven't found anything quite like what I want to do. 
However, it seems like a common problem so perhaps
someone can help me.

I have two pages, one of which I will call query.jsp,
and the other report.jsp; I have action mappings for
them that I will call getQueryPage.do and getReport.do
respectively.  The getQueryPage.do is a
org.apache.struts.actions.ForwardAction, the
getReport.do is an action of my own with does the
actual work to generate the report.

I have a set of select boxes on query.jsp, and also
some text boxes.  I am using a DynaValidatorForm to
encapsulate these values; I will call this ActionForm
queryForm.  I am using the html:form and html:text
tags, and some custom tags to render the select boxes
(there is some slightly complicated logic to get the
collections for the other select boxes that is
encapsulated in the java code for the tags); so
query.jsp looks something like (greatly simplified;
not actual code)

<script>
function refreshPage( form )
{
   form.action = 'getQueryPage.do';
   form.submit();
}
</script>

<html:form action="getReport.do">
  <html:text property="startDate" />
  <html:text property="endDate" />
  <mytags:companyselect onchange="refreshPage(
this.form )" />
  <mytags:branchselect />
  <mytags:codeselect code="outletType" />
  <mytags:codeselect code="status" />
</html:form>

So this works fine for the initial page viewing; also
it works if validation fails; the html:text tags
remember their values, and I've written my tags to do
so as well.

When the value of the companyselect changes, the page
gets refreshed and my branchselect and codeselect
tages are updated as appropriate; however of course
the html:text values get lost. :-(

What I want is to be able to re-present the query.jsp,
but instead of re-initializing queryForm to use the
existing form in the request, like what happens when
validation fails (but without an error message, and
preferably using the same URL getQueryPage.do).

I'm new to struts, so I may be going about this all
wrong; it seems there must be an easy way to do this
since it seems like a pretty common requirement. 
Right now I can think of three approaches:

1) Don't use the html:text stuff at all, instead write
my own tag that looks first in the ActionForm for a
value, and if none is there looks in the http request
directly (this is basically what I am doing in the
mytags.branchselect and mytags.codeselect ).  Seems
wasteful.

2) in javascript refreshPage(), instead of changing
the action of the form set some dummy value to cause a
message-less validation error on the server, so that
the query page will get re-presented.  Seems awfully
hacky.

3) SOMEHOW tell struts not to create a new form for
the html:form tag if one already exists in the
request...this is what I really want to do but I don't
see a way to do it.

Or am I going about this all wrong?

Thanks in advance for any help you can give.  If there
is an example that I have overlooked that does this I
would appreciate being directed to it.

bye-Ben


                
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to