facebook

using interfaces in faces-config.xml

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #239682 Reply

    Dennie
    Member

    The validator for faces-config.xml gives an error when a Interface classname is used in a <managed-property>.
    I think this is valid.

    Example:

    
    <managed-bean>
        <managed-bean-name>modelService</managed-bean-name>
        <managed-bean-class>nl.dennie.model.impl.ModelImpl</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>modelView</managed-bean-name>
        <managed-bean-class>nl.dennie.ui.ModelView</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
        <managed-property>
            <property-name>modelService</property-name>
    <!--- THIS GIVES AN ERROR -->
            <property-class>nl.dennie.model.Model</property-class>
            <value>#{modelService}</value>   
        </managed-property>
    </managed-bean>

    Greetz Dennie

    #239706 Reply

    Riyad Kalla
    Member

    Dennie,
    A managed property has to be instantiatable (sp?) in order for the value to be set. For example if you were to use a hard value here, like: “Bob Williams”, and your property was not a String, and instead a CharSequence, it would be impossible for JSF to set that property for you at runtime which is what it is suppose to be able to do.

    #239954 Reply

    Dennie
    Member

    Hello rkalla,

    I understand the basics of managed beans. And if you check the config file, it uses a Impl(!) class which instantiates the property. By the way: This config works in JSF (myfaces).
    This is also very useful because I like to keep my source clean and work with interface properties instead of the hard implementing class. The red cross in my project just annoys me.

    Greets Dennie

    #239955 Reply

    I will fire the PR to allow using abstract classes/interfaces as managed beans properties and referenced beans.

    #239973 Reply

    Riyad Kalla
    Member

    Dennie,
    My appologies, it looks like this should get corrected soon.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: using interfaces in faces-config.xml

You must be logged in to post in the forum log in