7 Replies Latest reply: Oct 2, 2008 4:40 PM by Frank Nimphius-Oracle RSS

    using JSFUtils.setManagedBeanValue

    441570
      Hi,

      When trying to trouble shoot some code I have

      <code>
           DCBindingContainer bindings = (DCBindingContainer)JSFUtils.resolveExpression("#{bindings}");
      Boolean commitEnabledFlag = ((Boolean)JSFUtils.getManagedBeanValue("bindings.Commit.enabled"));
      </code>

      which returns true or false

      but if I try
      <code>
      bindings = (DCBindingContainer)JSFUtils.resolveExpression("#{bindings}");
      JSFUtils.setManagedBeanValue("bindings.Commit.enabled", false);
      </code>
      it returns

      ...
      Caused by: oracle.jbo.expr.JIEvalException: JBO-25077: Name enabled not found in the given object: Commit.
      ...


      any thoughts?

      thanks Joe.
        • 1. Re: using JSFUtils.setManagedBeanValue
          442652
          I'm not really sure the enabled property has a setter; I think the binding container sets it internally and that it's probably final. (I'm not 100% sure of this, but I think that it's true). Is there a reason you actually have to programmatically change the "enabled" property of the binding, rather than of the command component?
          • 2. Re: using JSFUtils.setManagedBeanValue
            470068
            Hi,

            In this case I think should be JSFUtils.resolveExpression("#{bindings.Commit.enabled}"); Also check if Commit action is in added in PageDef.xml

            Kuba
            • 3. Re: using JSFUtils.setManagedBeanValue
              441570
              Hi Avrom and Kuba,


              extract from JSFUtils.java
              ...

              /**
              * Convenience method for setting the value of a managed bean by name
              * rather than by expression.
              * @param beanName name of managed bean
              * @param newValue new value to set
              */
              public static void setManagedBeanValue(String beanName, Object newValue) {
              StringBuffer buff = new StringBuffer("#{");
              buff.append(beanName);
              buff.append("}");
              setExpressionValue(buff.toString(), newValue);
              }

              /**
              * Convenience method for resolving a reference to a managed bean by name
              * rather than by expression.
              * @param beanName name of managed bean
              * @return Managed object
              */
              public static Object getManagedBeanValue(String beanName) {
              StringBuffer buff = new StringBuffer("#{");
              buff.append(beanName);
              buff.append("}");
              return resolveExpression(buff.toString());
              }

              Is there a reason you actually have to programmatically change the "enabled" property of the binding
              I am using Code from Andrejus Baranovskis's Blog: JDeveloper 11g - CRUD in ADF Form Component which uses
              JSFUtils.getManagedBeanValue("bindings.Commit.enabled")
              On my CreatePage I use #{bindings.CreateInsert.execute} as a method call which seems to set
              bindings.Commit.enabled to true. In the sample "CRUD in ADF Form Component" #{bindings.Commit.enabled}
              is set to false on this page. So when I do a Rollback on that page I also wanted to set #{bindings.Commit.enabled} to
              false, which then allows page navigation, as it's wired not to navigate if #{bindings.Commit.enabled} is true.

              Joe.
              • 4. Re: using JSFUtils.setManagedBeanValue
                John Stegeman
                Joe,

                I agree with Avrom's assessment. I don't believe either that you can set the value of the enabled property on the binding like that, sorry.

                John
                • 5. Re: using JSFUtils.setManagedBeanValue
                  441570
                  Hi John,
                  I'm not really sure the enabled property has a setter
                  Thanks, I'll work on a different approach.

                  Joe.
                  • 6. Re: using JSFUtils.setManagedBeanValue
                    487442
                    Hi Joe,

                    As mentioned before, this won't work. In order for a setValue to work, a setter must be present on the object you're working on and I don't think it exists on OperationBindings.


                    Regards,

                    ~ Simon
                    • 7. Re: using JSFUtils.setManagedBeanValue
                      Frank Nimphius-Oracle
                      ... no there is no getter/setter for this

                      Frank