3 Replies Latest reply: Aug 23, 2013 3:22 AM by Cvele_new_account RSS

    Refreshing a UI field on Button click.

    879338

      I have and input text and a search icon next to in on UI. On click on search icon I show a popup and on click of OK button on popup I set a value in pageFlowScope and tries to refresh input text. Input text value is same pageFlowScope variable so I was expecting it to show value in input text. But its not happening.

       

      jsff code

      <?xml version='1.0' encoding='UTF-8'?>

      <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"

      xmlns:af="http://xmlns.oracle.com/adf/faces/rich"

      xmlns:f="http://java.sun.com/jsf/core">

        <af:panelLabelAndMessage label="Label 1" id="plam1">

          <af:inputText id="it1" value="#{pageFlowScope.pSecureByAdminRole}"/>

          <f:facet name="end">

                 <af:commandImageLink id="cil1" icon="/adf/webcenter/find_ena.png" partialSubmit="true" actionListener="#{backingBeanScope.RelationshipBean.launchSearchRolePopup}" immediate="true"/>

          </f:facet>

        </af:panelLabelAndMessage>

        <af:popup id="p1" binding="#{backingBeanScope.RelationshipBean.searchRolePopup}">

          <af:dialog id="d1" type="none">

                 <f:facet name="buttonBar">

                      <af:commandButton text="Ok" id="cb1" actionListener="#{backingBeanScope.RelationshipBean.handleRoleSearchOK}" partialSubmit="true"/>

                 </f:facet>

          </af:dialog>

        </af:popup>

      </jsp:root>


      Bean code

       

          public void launchSearchRolePopup(ActionEvent actionEvent) {

                      ADFUtils.showPopup(this.getSearchRolePopup(), null, null, null);

          }

       

          public void handleRoleSearchOK(ActionEvent actionEvent){

                 ADFUtils.getPageFlowScope().put("pSecureByAdminRole", "TEST");

                 this.getSearchRolePopup().hide();

                 ADFUtils.refreshUI(this.getSecureByAdminRoleOnNewDocument());

          }


      ADFUtil Code:

       

          public static void showPopup(RichPopup popup,UIComponent alignComponent,RichPopup.PopupHints.AlignTypes alignType,RichPopup.PopupHints additionalHints ){

                 FacesContext context = FacesContext.getCurrentInstance();

                 if(additionalHints == null)

                      additionalHints = new RichPopup.PopupHints();

                 String alignId = null;

                 if(alignComponent != null){

                          alignId = alignComponent.getClientId(context);

                          additionalHints.add(RichPopup.PopupHints.HintTypes.HINT_ALIGN_ID, alignId);

                  }

           

                  if(alignType != null){

                      additionalHints.add(RichPopup.PopupHints.HintTypes.HINT_ALIGN,  alignType);

                 }    

           

                 popup.show(additionalHints);

          }

       

          public static void refreshUI(UIComponent uiComponent){

                AdfFacesContext adfctx = AdfFacesContext.getCurrentInstance();

                adfctx.addPartialTarget(uiComponent);

          }

       

      Input text does not show new value (TEST). If I just click on browser refresh icon, it starts showing TEST. By that way it looks like refresh issue only.

      I tried setting partial trigger of input-text to refer to OK button of popup but no success.

       

      Thanks

      Sanjeev.

        • 1. Re: Refreshing a UI field on Button click.
          Cvele_new_account

          <af:inputText id="it1" value="#{pageFlowScope.pSecureByAdminRole}"/>


          Whether this component you need to freshen up?

          I do not see that is binded to the 'SecureByAdminRoleOnNewDocument' backing bean property

          What exactly getSecureByAdminRoleOnNewDocument()) method returns ?

          • 2. Re: Refreshing a UI field on Button click.
            879338

            I do have binding but some how I missed to that while posting in forum. Actuall jsff code is like

            <?xml version='1.0' encoding='UTF-8'?>

            <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"

            xmlns:af="http://xmlns.oracle.com/adf/faces/rich"

            xmlns:f="http://java.sun.com/jsf/core">

              <af:panelLabelAndMessage label="Label 1" id="plam1">

                <af:inputText id="it1" value="#{pageFlowScope.pSecureByAdminRole}" binding="#{backingBeanScope.RelationshipBean.secureByAdminRoleOnNewDocument}"/>

                <f:facet name="end">

                       <af:commandImageLink id="cil1" icon="/adf/webcenter/find_ena.png" partialSubmit="true" actionListener="#{backingBeanScope.RelationshipBean.launchSearchRolePopup}" immediate="true"/>

                </f:facet>

              </af:panelLabelAndMessage>

              <af:popup id="p1" binding="#{backingBeanScope.RelationshipBean.searchRolePopup}">

                <af:dialog id="d1" type="none">

                       <f:facet name="buttonBar">

                            <af:commandButton text="Ok" id="cb1" actionListener="#{backingBeanScope.RelationshipBean.handleRoleSearchOK}" partialSubmit="true"/>

                       </f:facet>

                </af:dialog>

              </af:popup>

            </jsp:root>


            One strange thing I noticed is if I disable input component (disable = "true") , it starts refreshing it.


            Any suggestions.


            Thanks

            Sanjeev

            • 3. Re: Refreshing a UI field on Button click.
              Cvele_new_account

              As a workarround, you can try refresh component in popupCanceledListener, OR with


               

              <af:clientListener method="popupClosedListener" type="popupClosed"/>

                <af:serverListener type="serverPopupClosed" method="#{testBean.serverPopupClosedListener}"/>

               

              take a look at:

              http://docs.oracle.com/cd/E23943_01/apirefs.1111/e12419/tagdoc/af_popup.html