3 Replies Latest reply: Jan 17, 2013 7:32 AM by 886919 RSS

    How to call <af:ServerLinstener> from jsff page

    619214
      Hi,

      our requirement is: Removing 'Advanced' button from LOV component


      I have downloaded a jws which resolves this requirement, however the problem is calling a bean method from <af:ServerlListener> tag

      There are two funtions in downloaded example 'lovlaunch' and 'lovAfterLaunch'. The first one 'lovlaunch' is called from 'LauchPopupListener' the other function has to be called with below tag in *.jspx

      <af:serverListener type="lovafterlaunch"
      method="#{removeAdvanceButtonBean.lovAfterLaunch}"/>

      The method 'lovAfterLaunch' is called perfectly from *.jspx as the above tag is placed under form tag <af:form>

      Our requirement is to call the same method from *.jsff page, i could not find <af:form> tag in *.jsff page.

      Please help me on this requirement.

      Thanks,
      Hemanth.

      Edited by: Hemanth C on Jan 17, 2013 2:20 AM
        • 1. Re: How to call <af:ServerLinstener> from jsff page
          Frank Nimphius-Oracle
          Hi,

          what triggers the server listener call? If it is a client listener then add the server listener next to the client listener. If the call is from Java then place the af:serverListener as a child of a component that you can access from JavaScript using the AdfPage.PAGE.findComponentByAbsoluteId call.

          If the call is from a popup listener then af:serverListener should be a child of the af:popup component

          Frank
          • 2. Re: How to call <af:ServerLinstener> from jsff page
            619214
            Hi Frank,

            Thanks for reply.

            1. The component we are using is "inputlistofvalues", when i tried to place the <af:ServerListener> under </af:inputListOfValues> component as child of it, there is an error message saying that it is not a valid child component.



            lovLaunch is invoked on LaunchPopupListener of "inputlistofvalues" component.

            lovAfterLaunch is invoked from <af:ServerListener> tag

            All this steps are from a example .jws downloaded from a blog. In that <b><af:ServerListener></b> is called from a jspx, here in my case i am trying to call from jsff. In the example it is suggested to call <b><af:ServerListener></b> from a <af:form> tag like below. where as in jsf i dont have <af:form id="f1">.
            -------------------------------
            <f:view>
            <af:document id="d1">
            <af:messages id="m1"/>
            <af:form id="f1">
            <af:serverListener type="lovafterlaunch"
            method="#{lovBean.lovAfterLaunch}"/>
            ---------------------------------

            these are the two functions i am using:

            #############################################

            public void lovLaunch(LaunchPopupEvent launchPopupEvent) {
            RichInputListOfValues inputListOfValues = (RichInputListOfValues)launchPopupEvent.getComponent();
            if (inputListOfValues != null) {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            String clientId = inputListOfValues.getClientId(facesContext);
            StringBuffer scriptBuffer = new StringBuffer();
            scriptBuffer.append(" var docComp = AdfPage.PAGE.findComponent(\"f1\"); var comp = AdfPage.PAGE.findComponent(\"");
            scriptBuffer.append(clientId).append("\"); ");
            scriptBuffer.append(" if (comp != null && docComp != null) { var CompId = comp.getId(); ");
            scriptBuffer.append(" AdfCustomEvent.queue(docComp,\"lovafterlaunch\",{compId:CompId},true);}");
            String script = scriptBuffer.toString();
            ExtendedRenderKitService erks = Service.getService(facesContext.getRenderKit(), ExtendedRenderKitService.class);
            erks.addScript(facesContext, script);
            }
            // Add event code here...
            }

            public void lovAfterLaunch(ClientEvent clientEvent) {
            if (clientEvent.getParameters().size() > 0 && clientEvent.getParameters().get("compId") != null) {
            String compId = clientEvent.getParameters().get("compId").toString();
            RichInputListOfValues inputListOfValues = (RichInputListOfValues)JSFUtil.findComponentInRoot(compId);
            if (inputListOfValues != null) {
            Iterator<String> facetNames = inputListOfValues.getFacetNames();
            RichPopup richPopup = null;
            String facetName = null;
            UIComponent componentFacet = null;
            UIComponent componentdialog = null;
            while(facetNames.hasNext()) {
            facetName = facetNames.next();
            if (facetName != null) {
            componentFacet = inputListOfValues.getFacet(facetName);
            if (componentFacet != null && componentFacet instanceof RichPopup) {
            richPopup = (RichPopup)componentFacet;
            break;
            }
            }
            }
            if (richPopup != null) {
            List<UIComponent> uiCompList = richPopup.getChildren();
            if (uiCompList.size() > 0) {
            componentdialog = uiCompList.get(0);
            if (componentdialog != null && componentdialog instanceof RichDialog) {
            RichDialog richDialog = (RichDialog)componentdialog;
            if (richDialog != null) {
            richDialog.setAffirmativeTextAndAccessKey("&OK");
            richDialog.setCancelTextAndAccessKey("&Cancel");
            AdfFacesContext.getCurrentInstance().addPartialTarget(richDialog);
            if (richDialog.getChildCount() == 1 && richDialog.getChildren().get(0) != null
            && richDialog.getChildren().get(0) instanceof RichPanelGroupLayout) {
            RichPanelGroupLayout panelGroupLayout = (RichPanelGroupLayout)richDialog.getChildren().get(0);
            uiCompList = panelGroupLayout.getChildren();
            if (uiCompList.size() > 0 && uiCompList.get(0) != null &&
            uiCompList.get(0) instanceof RichPanelHeader) {
            RichPanelHeader richPanelHeader = (RichPanelHeader)uiCompList.get(0);
            if (richPanelHeader.getChildCount() == 1 && richPanelHeader.getChildren().get(0) != null &&
            richPanelHeader.getChildren().get(0) instanceof RichQuery) {
            RichQuery richQuery = (RichQuery)richPanelHeader.getChildren().get(0);
            if (richQuery != null) {
            richQuery.setModeChangeVisible(false);
            AdfFacesContext.getCurrentInstance().addPartialTarget(richQuery);
            }
            }
            }
            }
            }
            }
            }
            }
            }
            }
            }

            ######################################################

            Edited by: Hemanth C on Jan 17, 2013 3:27 AM
            • 3. Re: How to call <af:ServerLinstener> from jsff page
              886919
              Hemanth C wrote:
              Hi,

              our requirement is: Removing 'Advanced' button from LOV component
              Hi Hemanth
              Is this a declarative LOV ? (eg: StatesLOV Created at Design time by specifying a StatesLOVVO with FilterByState_ViewCriteria defined for the model).

              If so, you can turn of Advanced by going to the FilterByState_ViewCriteria of StatesLOVVO and setting the mode to be available as "Basic" only from UI Hints section for your attributes. This will take off the Advanced Button.

              Edited by: basu008 on Jan 17, 2013 5:32 AM