incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Böhringer Jochen <Jochen.Boehrin...@tcc-products.de>
Subject AW: Define Trinidad navigation in faces-config.xml using action methods instead of outcomes
Date Thu, 09 Nov 2006 13:35:42 GMT
Hello Stefan,

 

Thanks for the hint regarding .AFRequiredIconStyle. 

 

I also got my menu to work now. For everyone who is interested in the solution:

 

I developed a managed bean doing the conversion for me:

 

<managed-bean>

  <managed-bean-name>method</managed-bean-name>

  <managed-bean-class>de.tccproducts.kn.jsf.util.ActionBindingConverter</managed-bean-class>

  <managed-bean-scope>none</managed-bean-scope>

 </managed-bean>

 

 

I can reference this bean's getBinding method in the navigation items as MethodBinding

 

<managed-bean>

  <managed-bean-name>mtn_kape_createKeyAccount</managed-bean-name>

  <managed-bean-class>de.tccproducts.kn.jsf.model.MenuTreeNode</managed-bean-class>

  <managed-bean-scope>none</managed-bean-scope>

  <managed-property>

   <property-name>action</property-name>

   <property-class>javax.faces.el.MethodBinding</property-class>

   <value>#{method.binding['keyAccountProfileEditorController.showCreateKeyAccount']}</value>

  </managed-property>

[...]

 

The code of the ActionBindingConverter:

 

public class ActionBindingConverter {

 

      private MethodBinding getMethodBinding(String methodName) {

            return FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{"
+ methodName + "}", null);

      }

      

      public Map<String, MethodBinding> getBinding() {

            return new HashMap<String, MethodBinding>() {

                  private static final long serialVersionUID = 0L;

                  @Override

                  public int size() {

                        return 1;

                  }                 

                  @Override

                  public MethodBinding get(Object key) {

                        return getMethodBinding((String) key);

                  }

            };

      }

}

 

Regards

Jochen

 

 

-----Ursprüngliche Nachricht-----
Von: Stefan Podkowinski [mailto:spodxx@gmail.com] 
Gesendet: Mittwoch, 8. November 2006 22:41
An: adffaces-user@incubator.apache.org
Betreff: Re: Define Trinidad navigation in faces-config.xml using action methods instead of
outcomes

 

I'm not sure if I got you right. But I guess it would be a good idea

creating the getAction() method in your MenuTreeNode class instead of

the keyAccountProfileEditorController. The MenuTreeNode would just

delegate to the appropriate controller (which has been injected

before) based on its configuration through its properties.

 

As for the required icon, you can hide it easily by adding the

following stylesheet:

.AFRequiredIconStyle {display:none;}

 

On 11/8/06, Böhringer Jochen <Jochen.Boehringer@tcc-products.de> wrote:

> Hello,

> 

> 

> 

> I have adapted the example from the Trinidad documentation (http://incubator.apache.org/adffaces/devguide/navigation.html)
about Navigation to fit my needs, but I have one major problem. I want to use the approach
to have the navigation hierarchy configured in the facelets-config.xml as a tree of managed
beans describing the label and action of the menu items. This way I can easily use components
like <tr:breadCrumbs> to render the way the user walked down the navigation path.

> 

> 

> 

> This works pretty good if I specifiy an outcome in this configuration for every item
like this snippets shows:

> 

> 

> 

> <managed-bean>

> 

>   <managed-bean-name>mtn_kape_editKeyAccount</managed-bean-name>

> 

>   <managed-bean-class>de.tccproducts.kn.jsf.model.MenuTreeNode</managed-bean-class>

> 

>   <managed-bean-scope>none</managed-bean-scope>

> 

>   <managed-property>

> 

>    <property-name>action</property-name>

> 

>    <property-class>java.lang.String</property-class>

> 

>    <value>showSearchKeyAccount</value>

> 

>   </managed-property>

> 

>   <managed-property>

> 

>    <property-name>description</property-name>

> 

>    <property-class>java.lang.String</property-class>

> 

>    <value/>

> 

>   </managed-property>

> 

>   <managed-property>

> 

>    <property-name>icon</property-name>

> 

>    <property-class>java.lang.String</property-class>

> 

>    <value/>

> 

>   </managed-property>

> 

>   <managed-property>

> 

>    <property-name>label</property-name>

> 

>    <property-class>java.lang.String</property-class>

> 

>    <value>Edit Key Account</value>

> 

>   </managed-property>

> 

>   <managed-property>

> 

>    <property-name>viewId</property-name>

> 

>    <property-class>java.lang.String</property-class>

> 

>    <value>/kape_editKeyAccount.xhtml</value>

> 

>   </managed-property>

> 

>  </managed-bean>

> 

> 

> 

> But I want to be able to use action methods instead of outcomes in the configuration,
because I have to do initialization work before showing some of my screens.

> 

> 

> 

>   <managed-property>

> 

>    <property-name>action</property-name>

> 

>    <property-class>java.lang.String</property-class>

> 

>    <value>#{keyAccountProfileEditorController.showSearchKeyAccount}</value>

> 

>   </managed-property>

> 

> 

> 

> But if I try to define a method binding in the action property of the managed bean I
get this exception:

> 

> 

> 

> Caused by: javax.faces.FacesException: Property action references object in a scope with
shorter lifetime than the target scope none

> 

>       at org.apache.myfaces.config.ManagedBeanBuilder.initializeProperties(ManagedBeanBuilder.java:164)

> 

> 

> 

> The reason is clear. The managed bean keyAccountProfileEditorController is on session
scope an the navigation is defined in scope none. But even if I switch all navigation items
to the session scope I get exceptions because the engine tries to evaluate the expression
as a bean property and not as a method binding. So the engine tries to find a method getShowSearchKeyAccount
in my controller bean. Is there a workaround to realize what I want to do or do I have to
rethink about my design.

> 

> 

> 

> Btw. how can I disable the star in front of an inputText field which is marked as required.
I have tried to set the content in my skin, but this does not help. Only setting the color
to the same as the background is not sufficient for me, because the layout is broken.

> 

> 

> 

> /** Style class that styles the .AFRequiredIcon icon. */

> 

> .AFRequiredIconStyle { content:""; }

> 

> 

> 

> 

> 

> Regards

> 

> Jochen

> 

> 

> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message