I would open the new javascript window by calling an action like:

window.open("/app/report/Search.do?parameterXY=foo" ....

The action could perform your search with the corresponding parameters. To
have dynamic values in the javascript you can always use your form bean eg.

window.open('/app/report/Search.do?parameterXY=<bean:write name="searchForm"
property="searchStuff" />','myWindow','toolbar=none')

Good night ;-)
Koni

>-- Original-Message --
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>From: "Au-Yeung, Stella H" <[EMAIL PROTECTED]>
>To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
>Subject: RE: Pop-up a window on Submit
>Date: Tue, 12 Aug 2003 15:52:35 -0400
>
>
>Well I have succeeded opening a window in struts-based jsp file.  But the
>window that got opened does not contain the data I retrieved from the data.
>The data was set in my formBean in my Action class.  I tried two different
>methods:
>
>Method#1: my jsp has been modified to the following
><script type="text/javascript" langugage="JavaScript">
><!--
>function submitForm(frm)
>{
>win = window.open( "/app/report/Search","myWindow","toolbar=none");
>win.resizeTo( 450, 350);
>return true;      
>}
>//-->
></script>
><html:form  name="frm" action="/app/report/Search" method="post"
>onsubmit="return submitForm(document.frm)">
>With method#1, my normal 'mainReport.jsp' still displayed in the original
>window with the result set of data that was retrieved from the database.
>  A
>small window was also opened but with error 404.   But I want
>"MainReport.jsp with the result" to be displayed in the new window.
>
>
>Method#2: my jsp has been modified to the following
><html:form  action="/app/report/Search" method="post">
><logic:equal name="SearchFormBean" property="result" scope="request"
>value="ok">
><script type="text/javascript" langugage="JavaScript">
><!--
>win = window.open( "","myWindow","toolbar=none");
>win.resizeTo( 750, 450);
>//-->
></script>
></logic:equal>
>In my Action class, the "result' property is set to "ok" when data are
>retrieved from the DB successfully.
>
>With method#2, a 'blank' new window is opened.  The original window didn't
>change, it has the search filters.  But I want the result to be displayed
>in
>the new window.
>
>
>My struts-config file:
><action    path="/app/report/Search"
>           type="com.test.action.report.ReportAction"
>           name="SearchFormBean"
>           scope="request"
>           validate="false">
>         <forward name="Content" path="/app/report/MainReport.jsp"/>
>         <forward name="ContentError" path="/app/report/Search.jsp"/>
></action>
>
>I guess I don't know what to put as the 'url' parameter in the window.open()
>method in order for MainReport.jsp to be displayed in the new window with
>the retrieved data.   As you can see, I tried using "/app/report/Search"
>and
>"".  Neither one works.   
>
>Any idea???
>
>Pat
>
>
>-----Original Message-----
>From: Koni [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, August 12, 2003 11:26 AM
>To: Struts Users Mailing List
>Subject: RE: Pop-up a window on Submit
>
>
>- When you look at the html code, check if the result value (ok) is passed
>correctly. Otherwise it does not work.
>
>- <javascript:window.open("", "myWindow", 'toolbar,width=450,height=500')
>???
>Here you have to figure out how to open the JSP page with javascript.
>Javascript
>documentation eg. selfhtml will help.
>
>Koni
>
>>-------- Original Message --------
>>Subject: RE: Pop-up a window on Submit
>>Date: Tue, 12 Aug 2003 10:39:42 -0400
>>From: Au-Yeung, Stella H <[EMAIL PROTECTED]>
>>Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
>>To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
>>
>>Hi Koni:
>>I must have misunderstood what you adviced me to do because I couldn't
get
>>it working on what you suggested.   This is what I did:
>>
>>I added the logic tag in my jsp:
>><logic:equal name="SearchFormBean" property="result" scope="request"
>>value="ok">
>><javascript:window.open("", "myWindow", 'toolbar,width=450,height=500')
>></logic:equal>
>>===> the rest of this jsp file is just a table to display my data.
>>
>>
>>I added a new property "result" into my formBean and also its getter and
>>setter.
>>private String result;
>>
>>
>>Then in my Action class I added the following call to the setter when my
>>data are retrieved successfully:
>>if (formBean.isMainReportAction())
>>{
>>    this.validateAction(formBean, request, errors);  // validate search
>>filters
>>    if(errors.empty())
>>    {
>>      retrieve data for main report and display main report
>>      formBean.setResult("ok");  // IF EVERYTHIANG IS OK, SET result="ok"
>>so jsp will pop up new wdw
>>    }
>>    else
>>        displayed error message in the original window
>>}
>>
>>But when I ran this, no window is pop-up.  The data is still displaying
>in
>>the original window.
>>Did I miss something that you tried to tell me?  Thx...
>>
>>Pat
>>
>>
>>
>>-----Original Message-----
>>From: Koni [mailto:[EMAIL PROTECTED]
>>Sent: Tuesday, August 12, 2003 7:00 AM
>>To: [EMAIL PROTECTED]
>>Subject: Re: Pop-up a window on Submit
>>
>>
>>Hi Pat
>>
>>I solved the validation problem (your question 2) as described in many
>>examples:
>>
>>In struts-config.xml, add 'input' to your action mapping.
>>...
>><action path="/app/report/Search"
>>          type="com.test.action.report.ReportAction"
>>          name="SearchFormBean
>>         scope="request"
>>      validate="false"
>>         input="/thePage.jsp"> // <---- !!
>>...
>>
>>MyAction.java:
>>...
>>   ActionErrors errors = new ActionErrors();
>>   if ( ! formBean.isMainReportAction() )
>>   {
>>      errors.add(ActionErrors.GLOBAL_ERROR,
>>                 new ActionError("error.my.error.message"));
>>   }
>>   // Report any errors we have discovered back to the original form
>>   if (!errors.isEmpty())
>>   {
>>      saveErrors(request, errors);
>>      // go back to the input page
>>      return  new ActionForward(mapping.getInput());
>>   }
>>...
>>
>>
>>thePage.jsp:
>>Example of displaying errors in .jsp
>>...
>>   <logic:messagesPresent>
>>     <UL>
>>       <html:messages id="errors">
>>         <LI><bean:write name="errors"/></li>
>>       </html:messages>
>>     </ul>
>>   </logic:messagesPresent>
>>...
>>
>>You could solve your pop-up problem with <logic:equal> in your .jsp!
>>
>><logic:equal name="myForm" property="result" scope="request" value="ok">
>>    <javascript:open.your.pop.up.some.how>
>></logic:equal>
>>
>>Hope it helps.
>>Koni
>>
>>
>>>Au-Yeung, Stella H wrote:
>>> Hi:
>>> The bottom of my Search.jsp has two buttons.  They are for displaying
>>> different report (a Main report and a Procedure Summary):
>>> 
>>> <html:submit property="mainReport"><bean:message
>>> key="button.mainReport"/></html:submit>
>>> <html:submit property="procedureSummary"><bean:message
>>> key="button.procedureSummary"/></html:submit>
>>> 
>>> In my Struts Action class ReportAction I do the following:
>>> if (formBean.isMainReportAction())
>>> {
>>>   this.validateAction(formBean, request, errors);  // validate search
>>> filters
>>>   if(errors.empty())
>>>     retrieve data for main report and display main report
>>>   else
>>>       displayed error message
>>> }
>>> else if (formBean.isProcedureSummaryAction())
>>> {
>>>   this.validateAction(formBean, request, errors);   // validate search
>>> filters
>>>   if(errors.empty())
>>>     retrieve data for procedure summary report
>>>       << forward to the template "ProcSummTemplate"
>>>   else
>>>       displayed error message
>>> }
>>> 
>>> My struts-config file sort of like this:
>>> <global-forwards>
>>>     <forward name="ProcSummTemplate"
>>> path="/app/report/ProcedureSummary.jsp"/>
>>> </global-forwards>
>>> 
>>> <action    path="/app/report/Search"
>>>            type="com.test.action.report.ReportAction"
>>>            name="SearchFormBean"
>>>            scope="request"
>>>            validate="false">
>>>         <forward name="Content" path="/app/report/MainReport.jsp"/>
>>>       <forward name="ContentError" path="/app/report/Search.jsp"/>
>>> </action>
>>> 
>>> All the above works fine, but now I need to enhance it to do these:
>>> - If there are no validation errors, pop-up a new window to display the
>>> selected report (MainReport.jsp or ProcedureSummary.jsp)
>>> - If there are validation errors, stay on the same window to display
>>> validation messages in Search.jsp so user can reenter search filters.
>>> My questions are:
>>> 1) How do I pop up a new window with the <html:submit> tag?  Since I
>>cannot
>>> do onSubmit()="return popUpAWindow()" inside the <html:submit> tags
>>> 2) How do I force Struts to stay in the same window if there are
>>validation
>>> errors, otherwise do the pop-up? My validation method is in the Action
>>class
>>> and not a javascript function.   
>>> 
>>> Thanks in advance.....
>>> Pat
>>> 
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>-- 
>>Koni Roth,
>>  - http://www.rothweb.ch
>>  - http://www.rothconsulting.com
>>  - Jump and the earth will rise to meet you!
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>


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

Reply via email to