Skip to Content
author's profile photo
Former Member

pop-up iView scenario problem

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.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • author's profile photo
    Former Member
    Apr 26, 2004 at 06:56 PM

    Hi,

    i think that if you pass the row number or the rowKey to the pop-up window then you save everything in the session object. Then you can get the data.

    Hope it helps a bit.

    MB

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      The problem is that when you use htmlb to create an inputfield (or any other form controll), it doesn't generate an html form with element id equal to the htmlb id (due to avoid namespace conflicts).

      So, your javascript in the popup window must be dynamic 😊

      The best way to solve it, I belive is

      1. Retrive the actual name of the form element.

      Think you need to do something like the following

      <hbj:inputField

      id="blabla"

      type="string"

      maxlength="100"

      value=""

      >

      <%

      //not sure of this line, think there is tutorial on this in the documentation

      //The result is stored in a parameter for the jsp only

      String blablaId= context.getParamIdForComponent(this);

      %>

      </hbj:inputField>

      2. In the iView A (which opens the popup window) add a javascript method getPopupFormElementName(). This method should return the actual name of the html element (not the htmlb name). And is coded like

      function getPopupFormElementName(){

      return <%=blablaId%>

      }

      (here blablaId is the java variable found in 1)

      3. Then in the popup window you change the perform function to

      function perform() {

      var blablaId = opener.getPopupFormElementName();

      opener.document.getElementById(blablaId).value='foo'

      }

      As to the popup window in the tableview, I belive it should work (since it is also inside a form), the only problem could be if you are not able to get the real html id of the inputfield.

  • author's profile photo
    Former Member
    May 04, 2004 at 06:49 PM

    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()

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    May 06, 2004 at 09:07 AM

    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 comment
    10|10000 characters needed characters exceeded