1 2 Previous Next 22 Replies Latest reply: Apr 29, 2013 6:42 AM by Timo Hahn Go to original post RSS
      • 15. Re: navigation outside of an application
        Habib.Eslami
        I know I can set the destination and targetframe in the code but I don't know how to run af:Gobutton's navigation through the code.

        Habib
        • 16. Re: navigation outside of an application
          Habib.Eslami
          Timo, in some conditions the page shouldn't navigate. I mean the url is null
          in this case what's the solution?

          Habib
          • 17. Re: navigation outside of an application
            Timo Hahn
            In this case you disable the goButton
                          <af:goButton text="Go after check condition" id="gb1" destination="#{pageFlowScope.GoTestBeam.url}"
                                       targetFrame="_blank" partialTriggers="sbc1"
                                       disabled="#{!pageFlowScope.GoTestBeam.cond}"/>
            Timo
            • 18. Re: navigation outside of an application
              Habib.Eslami
              Thanks, in the follow case when I run the application this exception raises : java.lang.NullPointerException

              public String getUrl() {
              String tmp = inoutText.getValue().toString();

              if ( tmp.equals("-1")) {
              this.url = "http://www.google.com";

              } else if(tmp.equals("1")) {
              this.url = "http://www.yahoo.com";

              }else{
              //the page shouldn't navigate

              }
              return this.url;
              }



              <af:goButton text="Go after check condition" id="gb1" destination="#{pageFlowScope.GoTestBeam.url}"
              targetFrame="_blank"/>




              Habib
              • 19. Re: navigation outside of an application
                thishum
                hi,
                public String getUrl() {
                String tmp = inoutText.getValue().toString();

                code it like this way...

                String tmp = (String)inoutText.getValue();

                in first time inoutText field does not have value..

                and also if ( tmp.equals("-1")) {

                put it like *if (("-1").equals(tmp) ){*
                thks..
                • 20. Re: navigation outside of an application
                  Timo Hahn
                  What exactly is 'inoutText'?
                  Which values can this variable have?
                  If ' inoutText' is an af:inputText component you have bound to the bean, your bean should be in request scope. Beans holding component references should only be in request or backing bean scope.

                  As thishum said, you have to check the variables you use for 'null' as you get NPE otherwise.

                  Timo
                  • 21. Re: navigation outside of an application
                    Habib.Eslami
                    At first user fill input text component, then click the button and first a method from an application module run and on base of the method's result the url should be make and page navigate or it doesn't need to make any url and any navigation.

                    Object _obj = bindings.getOperationBinding("methodName").getResult();
                    String rslt= _obj. toString();
                    if (!("-1").equals(rslt)) {
                    this.url = "http://www.google.com";
                    } else {
                    //the page shouldn't navigate
                    }

                    In this case how can I first run the AM's method and then decide what to do?

                    Habib
                    • 22. Re: navigation outside of an application
                      Timo Hahn
                      OK, I setup a test case:
                      page code
                      <?xml version='1.0' encoding='UTF-8'?>
                      <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
                                xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
                        <jsp:directive.page contentType="text/html;charset=UTF-8"/>
                        <f:view>
                          <af:document id="d1">
                            <af:form id="f1">
                              <af:panelStretchLayout topHeight="50px" id="psl1">
                                <f:facet name="top">
                                  <af:outputText value="Conditional GoLink" id="ot1" inlineStyle="font-size:large;"/>
                                </f:facet>
                                <f:facet name="center">
                                  <af:panelGroupLayout id="pgl1">
                                    <af:inputText label="Label 1" id="it1" value="#{GoLinkBean.val}" autoSubmit="true" valueChangeListener="#{GoLinkBean.inputValueChangedListener}"/>
                                    <af:panelGroupLayout id="pgl2">
                                      <af:goButton text="goButton 1" id="gb1" disabled="#{!GoLinkBean.enableLink}" partialTriggers="it1" targetFrame="_blank"
                                                   binding="#{GoLinkBean.golink}" destination="#{GoLinkBean.targetUrl}"/>
                                    </af:panelGroupLayout>
                                  </af:panelGroupLayout>
                                  <!-- id="af_one_column_header_stretched"  -->
                                </f:facet>
                              </af:panelStretchLayout>
                            </af:form>
                          </af:document>
                        </f:view>
                        <!--oracle-jdev-comment:preferred-managed-bean-name:GoLinkBean-->
                      </jsp:root>
                      bean code (bean is registerd in request scope):
                      package de.hahn.xyzxyz.view.golink;
                      
                      import javax.faces.event.ValueChangeEvent;
                      
                      import oracle.adf.view.rich.component.rich.nav.RichGoButton;
                      
                      import oracle.adf.view.rich.context.AdfFacesContext;
                      
                      import org.apache.myfaces.trinidad.event.AttributeChangeEvent;
                      
                      public class GoLinkBean {
                          String val;
                          Boolean enableLink = false;
                          private RichGoButton golink;
                      
                          public GoLinkBean() {
                          }
                      
                      
                      
                          public void setVal(String val) {
                              this.val = val;
                          }
                      
                          public String getVal() {
                              return val;
                          }
                      
                          public void inputValueChangedListener(ValueChangeEvent valueChangeEvent) {
                              System.out.println("test");
                              // Add event code here...
                          }
                      
                          public void setEnableLink(Boolean enableLink) {
                              this.enableLink = enableLink;
                          }
                      
                          public Boolean getEnableLink() {
                              return enableLink;
                          }
                      
                          public String getTargetUrl() {
                              String url = null;
                              if ("-1".equalsIgnoreCase(getVal())) {
                                  setEnableLink(Boolean.TRUE);
                                  url = "http://www.google.com";
                              } else if ("1".equalsIgnoreCase(getVal())) {
                                  setEnableLink(Boolean.TRUE);
                                  url = "http://www.yahoo.com";
                              } else {
                                  setEnableLink(Boolean.FALSE);
                              }
                              AdfFacesContext.getCurrentInstance().addPartialTarget(golink);
                              return url;
                          }
                      
                          public void setGolink(RichGoButton golink) {
                              this.golink = golink;
                          }
                      
                          public RichGoButton getGolink() {
                              return golink;
                          }
                      }
                      Enter 1 or -1 in the inputText and tab out of the field. then click on hte now enabled goButton...
                      The one thing which is not solved is that you have to tab out of the inputText to activate the goButton. The reason is that the goButton is no command component and can't be activated directly from the bean. For this you have to use javascript.
                      My solution would be to use another input component which allows to directly set the value (e.g. a radio button group).

                      Timo
                      1 2 Previous Next