JSP calls the processing result returned by another page.

Source: Internet
Author: User

Description: List page: a page with search criteria.
Selectlist page: displays the data results generated by the List Search conditions.
Because our data List displays two parts, 1: Search for the page part list page. 2: Data Page part selectlist page.
To list the implementation process of this function from the perspective of reverse thinking:
1: Add a hidden domain data for each record on the data page (selectlist page), and read the values in the hidden domain after the selection.
Example:

 

Code

< Input Type = "Checkbox" Name = "Key" ID = "<C: Out value =" $ {VO. checkmissionid }" /> "Value =" < C: Out Value = "$ {VO. checkmissionid }"   /> "Onclick =" setcheckvalue (' < C: Out Value = "$ {VO. checkmissionid }"   /> ',' < C: Out Value = "$ {VO. checkmissionid }"   /> ') ">
< Input Type = "Hidden" ID = "TD _ <C: Out value =" $ {VO. checkmissionid }" /> "Value =" < C: Out Value = "$ {VO. checkmissionid }" /> ">

 

2: On the data page (selectlist page), add the "obtain selected data" method.

 

Code

Function Getresultinfo (){
VaR Flag = False ;
VaR Values = "" ;
VaR Results = "" ;
VaR Name = ' TD _ ' ;
VaR Checkboxs = Document. getelementsbyname ( " Key " );
For ( VaR I = 0 ; I < Checkboxs. length; I ++ ){
If (Checkboxs [I]. Checked ){
Flag = True ;
Name = Name + Checkboxs [I]. value;
Name = Jtrim (name );
Values = Document. getelementbyid (name). value;
If (I > 0 )
{
Results = Results + ' , ' + Values;
} Else {Results = Values ;}

Name = " TD _ " ;
}
}
If (FLAG)
Return Results;
Else
Return   False ;
}

 

 

3: Add a call to obtain data on the list page and return the method on the call page:

 

Function Addselectedmission ()
{
VaR Results = Result. Window. getresultinfo ();
If (Results ){
Parent. Window. returnvalue = Results;
Parent. Window. Close ();
}
Else Alert ( ' Select a task! ' );
}

 

Explanation: The result object here is the selectlist page. Result. Window. getresultinfo (); is the method used to obtain data on the selectlist page.
The selectlist is embedded into the list page by frame. ItsCodeAs follows:

 

Code

< Tr >
< TD >   <! -- Ui structure begin "Information List rolling area" -->
< Div Class = "Contentdiv" >
<! -- Ui structure begin "Information List table" -->
< IFRAME Name = "Result" ID = "Result" Scrolling = "Yes" Width = "100%" Height = "100%" SRC = '/Techtask/missionInfo-result.do? Method = missioninfoselectlist & VO. worktype = <Bean: Write Name = "Missioninfoform" Property = "VO. worktype" /> 'Frameborder = 0> </ IFRAME >
<! -- Ui structure end "Information List table" -->
</ Div >
<! -- Ui structure end "Information List rolling area" -->   </ TD >
</ Tr >

 

4: Add a button on the list page to trigger the addselectedmission () method.

 

< TD Class = "Btnmain" Onclick = "Addselectedmission ()" > Add selected enterprise </ TD >

 

5: Add a method on the called page to call this list page. And process the returned results.

 

Code

Function Selectmission (){
VaR URL, OPS;
URL =   " /Techtask/missionInfo-result.do? Method = missioninfolist & selecttype = 1 " ;
Ops =   " Dialogheight: 600px; dialogwidth: 800px; center: Yes; resizable: Yes; Status: yes; " ;
VaR A = Window. showmodaldialog (URL, "" , OPS );
Document. getelementbyid ( " VO. checkmissionids " ). Value = A; // Process the returned results.
}

6: Add a button on the page to trigger this event:

 

< TD Class = "Btnmain" Onclick = "Selectmission ()"   > Select administrative task </ TD >

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.