5 Replies Latest reply on Mar 24, 2011 5:20 AM by ilya_shaikovsky

    RF 4.x + commandLink + oncomplete from java

    forn

      Hello. Here is my code:

       

         UICommandLink utilLink = new UICommandLink();
                utilLink.getAttributes().put("reRender", util.getReRender());
                utilLink.setOncomplete(util.getOnClick());
                utilLink.setExecute("@this");
                HtmlGraphicImage utilImage = new HtmlGraphicImage();
                utilImage.setAlt(util.getName());
                utilImage.setTitle(util.getName());
                utilImage.setStyle("border:0;");
                // Добавляем утилиту в группу
                utilLink.getChildren().add(utilImage);
                utilGroup.getChildren().add(utilLink);

      Where util.getOnClick() = #{rich:component('createEssencePanel')}.show().

      But when I click to the button I get the next error:

      Сведения об ошибке на веб-странице
      Агент пользователя: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.6; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
      штамп времени: Tue, 22 Mar 2011 14:37:57 UTC
      
      Сообщение: Недопустимый знак
      Строка: 464
      Символ: 4
      Код: 0
      URI-код: http://localhost:7001/asge-portal/portal/javax.faces.resource/richfaces.js
      
      


      But when i try to parse #{rich:component('createEssencePanel')} as EL i get the error that rich:component is underfined

        • 1. RF 4.x + commandLink + oncomplete from java
          ilya_shaikovsky

          #{rich:component('createEssencePanel')}.show() should not be set as string directly but prior evaluated. on the client it should be document.getElementById('clientId').component.show()

           

          Use RichFunction.component function to get JS string. and add .show() to it.

          • 2. RF 4.x + commandLink + oncomplete from java
            forn

            Ilya Shaikovsky wrote:

             

            Use RichFunction.component function to get JS string. and add .show() to it.


            Thanks for answer. Where can i found API for using RichFunction, or can you write simply code for my example, pls.

            • 3. Re: RF 4.x + commandLink + oncomplete from java
              forn

              When i try use this code:

              UICommandLink utilLink = new UICommandLink();
                        utilLink.getAttributes().put("reRender", util.getReRender());
                        String strOnClick = util.getOnClick();
                        if ((strOnClick != null) && (!strOnClick.equals(""))) {
                          String[] onClick = strOnClick.split("\\.");
                          if (onClick.length == 2) {
                            String componentId = onClick[0];
                            String operation = onClick[1];
                            String componentViewId = RichFunction.component(componentId);
                            utilLink.setOncomplete(componentViewId + "." + operation);
                          }
                        }
              
              


              componentViewId - always null.

               

              My JSF:

               

               

              <h:form>
              <rich:panel>
                  <rich:toolbar id="functionalToolBar" itemSeparator="grid" binding="#{toolBarManager.functionalToolBar}"/>
                 
                  <!--  rich:toolbar id="functionalToolBar" itemSeparator="grid"
                   height="26px">
                   <rich:toolbarGroup>
                    <c:forEach var="util"
                     items="#{toolBarManager.utilsForFolderClass}">
                     <a4j:commandLink value="" oncomplete="${util.onClick}"
                      execute="@this" reRender="#{util.reRender}"
                      render="#{util.reRender}">
                      <h:graphicImage value="#{util.iconEnabled}" style="border:0;"
                       alt="#{util.name}" title="#{util.name}" />
                     </a4j:commandLink>
                     <h:outputText value="#{util.onClick}" />
                    </c:forEach>
                   </rich:toolbarGroup>
                  </rich:toolbar-->
                 </rich:panel>
                </h:form>
              
                <h:form id="createEssenceForm">
                 <!-- Создание сущности -->
                 <rich:popupPanel id="createEssencePanel" modal="true" moveable="true"
                  autosized="true"
                  onmaskclick="#{rich:component('createEssencePanel')}.hide()"
                  domElementAttachment="parent">
                  <f:facet name="header">
                   <h:outputText value="Создание сущности:" />
                  </f:facet>
                  <f:facet name="controls">
                   <h:outputLink value="Закрыть"
                    onclick="#{rich:component('createEssencePanel')}.hide(); return false;">Закрыть</h:outputLink>
                  </f:facet>
                 </rich:popupPanel>
                </h:form>
              
              
              • 4. Re: RF 4.x + commandLink + oncomplete from java
                forn

                document.getElementById('clientId').component.show()

                 


                document.getElementById('clientId').rf.component.show()

                • 5. Re: RF 4.x + commandLink + oncomplete from java
                  ilya_shaikovsky

                  here is what I've tried:

                      public String getCallApi() {

                          String id=(String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("componentId");

                          String api=(String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("apiFunc");

                          return RichFunction.component(id) + "." + api + "()" + ";";

                      }

                   

                  <h:form>

                            <a4j:commandButton oncomplete="#{userBean.callApi}">

                                      <a4j:param name="componentId" value="popup"/>

                                      <a4j:param name="apiFunc" value="show"/>

                            </a4j:commandButton>

                            <rich:popupPanel id="popup" modal="false" autosized="true"

                   

                   

                  works for me. Could add parameters easilly instead of just adding () and ; constantly.