Hi,
I wrote an iView that contains a tableView. The first column of the tableView contains an input field and a button (in each row). When I click on the button in a curtain row I want to call a "pop-up" screen (iView). I want to allow the user to select a value from a list and after the selection was made I want to put the selected value in the input field in the tableView (in the first iView).
What I can't figure is how to get the selected value from the pop-up iView to the first iView (to the correct place in the tableView)...
any example to a similiar scenario would be great.
please advise,
Thanks, Nir Marcu.
Best way to this senerio is
first you assign the eliment of hbj inputfield to a string
you declare String varible before you declare input field and assign value to that string before input field closed
example
String x ="" ;
<hbj: input field>
ID="some"
x = context.getElement(some)//here i doubt for this line of code browse images documentation for this
</hbj: inputfield>
when any button clicked you pass the parameter with url
you will get url by URL Generator
example strURL?"myfield="+x
you collect that value in next component by
request.getParameter("myfield")
and in popup jsp page in javascript code
you assign value by
opener.document.getElementbyID(myfield).value=foo;
window.close()
Hi All,
I had faced similar problem some time back .My scenario was in selection screen next to a input field I had provided a button ,on click of button a pop up iview displayed the possible values for the field ,on selection of the desired value by user pop up iview used to close and the selected value was populated in the desired field.
The reason why you are not able to put the value back on the parent screen is the parent screen is not a jsp screen and the id of the textfield is generated by the PRT which keeps changing all the time.
there is a way to find out the id of the textfield generated by PRT. Once you know this id then, you need to pass this id to the popup jsp page . Catch the parameter using request.getParameter() in the pop up window and assign its value to the openerField var of the javascript function.Below code snippets will help you
SelectionScreen.java
InputField inputLow = new InputField("PlantLow");
inputLow.setType(DataType.STRING);
inputLow.setMaxlength(100);
inputLow.setValue(profile.getProperty("PlantLow"));
g1.addComponent(1,3,inputLow);
myContext.setCurrentForm(myForm);
generatedLow = myContext.getParamIdForComponent(inputLow);
Image image_rect = new Image(request.getPublicResourcePath()+"/images/myLogo.gif",
"picture myLogo.gif");
image_rect.setWidth("18");
image_rect.setHeight("18");
Link link_circr = new Link("Right");
link_circr.addComponent(image_rect);
StringBuffer popUrlFirstPart = new StringBuffer(100);
String contextname =request.getComponentContext().getContextName();
String url = request.createPageURL(contextname);
int iLastSlashInUrl = url.lastIndexOf("/");
popUrlFirstPart.append(url.substring(0,iLastSlashInUrl));
int iLastSlash = contextname.lastIndexOf("/");
String strLastPart = contextname.substring(iLastSlash);
int iDotPosition = strLastPart.lastIndexOf(".");
popUrlFirstPart.append(strLastPart.substring(0,iDotPosition)).append(".Popup?InputField=");
String popUrlLow = popUrlFirstPart + generatedLow;
link_circr.setOnClientClick("window.open(\'" + popUrlLow + " ','NewWin','toolbar=no,status=no,width=400,height=400,resizable=no,left=300,top=180,scrollbars=yes');");
g1.addComponent(1,4,link_circr);
PopUpScreen.java
// doInitialization for PdvJspDynPage
protected void onEndPdvInitialization(IDataViewer pdv) {
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentContext context = request.getComponentContext();
IPortalComponentProfile profile = context.getProfile();
ensureBeanIsSetup();
ensurePopBeanIsSetup();
String ColumnLink = request.getParameter("InputField");
int index = ColumnLink.lastIndexOf("_");
String FormId = ColumnLink.substring(0,index);
mySelectionBean.setformId(FormId);
// if(mySelectionBean.getcomponentId()!= null ){
/* When the pop-up is invoked from some other
component reset the visible row to 1*/
myPopSelectBean.setVisibleRow("1");
myPopSelectBean.setClickedCellData("");
// }
mySelectionBean.setcomponentId(ColumnLink);
}
PopUp.jsp
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="MySelectionBean" scope="application" class="bean.SelectionBean" />
<jsp:useBean id="MyPopSelectBean" scope="application" class="bean.PopSelectBean" />
<hbj:content id="myContext" >
<hbj:page title="SAPPortals" >
<hbj:headInclude/>
<script>
var strSelectedData = '<%=MyPopSelectBean.getClickedCellData()%>';
EPCM.storeClientData( "urn:com.mynamespace", "selData", strSelectedData );
var data = EPCM.loadClientData( "urn:com.mynamespace", "selData" );
if(data != ''){
window.opener.document.<%=MySelectionBean.getformId()%>.<%=MySelectionBean.getcomponentId()%>.value = data;
window.opener.focus();
window.close();
}
</script>
<hbj:form id = "myForm">
<hbj:gridLayout width="100%">
<hbj:gridLayoutCell rowIndex="4" columnIndex="1" verticalAlignment="MIDDLE" horizontalAlignment="CENTER" width="100%">
<pdv:pdv id = "myJspPdv2" design="standard" headerVisible="false"/>
</hbj:gridLayoutCell>
</hbj:gridLayout>
</hbj:form>
</hbj:page>
</hbj:content>
Cheers
Anand
Add a comment