? on using faces-config bean properties

I like the idea of being able to set bean property values in faces-config - one because it's sort of self-documenting and two because I can change my app without re-compiling. Now from what I've read and from tests I've conducted, the bean is instantiated on first reference from a jsp - the framework calls the no-arg constructor and then calls the setter methods for any faces-config properties. Fine. But what if these properties are central to the bean's behavior - say they're used in the calculation of other properties. I don't have access to them in the constructor, and trying to do something in the setter for each property would be messy. Any ideas, or am I missing something fundamental?

You have the correct understanding. What I would do if I had a property that was dependant on the value of other properties is do the calculation in the getter of that property. As you said, trying to do it in the setter of the other properties would be messy to say the least. Also, be aware that JSF 1.0 has a bug in that it does not support setting nested properties from a faces-config file.

Similar Messages

  • I can't find the package, "com.sun.faces.config.beans"

    Hi. To research the implementation mechnism of JSF, I downloaded JSF reference implementation source JAR from javaserverfaces.dev.java.net.
    But when I unziped the JAR and import these files into eclipse to compile this project, a serials of compile errors occurred. Making a comparation between binary JAR and source JAR, I found that some files contained in binary JAR weren't in the source JAR. For example, com.sun.faces.config.beans package exists in the jsf-impl.jar, but not in jsf-impl's source JAR. I ensure that the binary files and source files have the same version.
    Any advice is welcome. THX.
    null

    There are three source projects for JSF. The jsf-api, jsf-impl, and jsf-tools. The jsf-tools one contains the package you're looking for.
    I never understood why the JSF developers organized their projects this way. Basically, it looks like the jsf-tools project gets compiled into the jsf-impl jar. Thus it's not 1 project to 1 JAR. And confuses people like us!
    CowKing

  • Faces-config bean won't resolve

    Hello,
    A while ago I was reading about a naming convention for spring beans. In spring I can create a bean like this:
    <bean id="prefix:beanId" class="org.company....">
    The prefix works similar to that of namespaces: when there's two beans from independent projects/modules sharing the same name the prefix helps to keep them unique.
    Anyway, when the faces-config.xml is parsed, it won't allow a colon in the name of the bean like so (an exception is thrown):
    <managed-bean>..........<value>#{prefix:beanId}</value></managed-bean>
    It does allow a period in there, such as:
    <managed-bean>..........<value>#{prefix.beanId}</value></managed-bean>
    However, after adjusting the bean identifier, it simply won't resolve. No exception, I'm getting null injected. When removing the periods, it does resolve.
    Why is that?
    Also, I'd like to know your experience with using id prefixes.
    Thanks,
    David

    well, i figured out the problem so thought to share with all aswell.
    all i changed was the name of the variable from mDept to dept.
    java beans has its own set of rules and naming conventions which i have not read much about but this problem had to do sumthing with that!
    just changing the name simply works fine!

  • Use Faces Managed Bean in javaScript

    Thanks in Advance
    Scenario:
    I have got a faces manged bean that constucts a string array .On my page i have got select one list box .Based on my selection ,message to be displayed at the bottom of the page or a pop up window .This string array corresponds to the list box items description.
    I am doing an onclick() event ,when i click on an item in the list ,display the pop up window with the message. here i need to call the FACES MANAGED BEAN
    to display the message in the pop up window.
    Can any one suggest a way for this to start.
    than u

    Use a ValueChangeEvent to do that.

  • How to configure multiple jsp files with diff beans in faces-config.xml??

    Hi All,
    I have 2 seperate jsp pages one is a login page and the other is the main application page.Now i am handling both the pages with seperate Bean class with respective setter and getter methods.How can i state the same in faces-config.xml file???..
    Is the below way correct???
    <?xml version='1.0' encoding='UTF-8'?>
    <!-- =========== FULL CONFIGURATION FILE ================================== -->
    <faces-config version="1.2"
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                       http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
        <managed-bean>
                <managed-bean-name>LoginForm</managed-bean-name>
                <managed-bean-class>useraccess.LoginForm</managed-bean-class>
                <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
        <navigation-rule>
                <from-view-id>/login.jsp</from-view-id>
            <navigation-case>
                <from-action>#{LoginForm.CheckValidUser}</from-action>
                <from-outcome>success</from-outcome>
                <to-view-id>/success.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-action>#{LoginForm.CheckValidUser}</from-action>
                <from-outcome>fail</from-outcome>
                <to-view-id>/fail.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>
        <managed-bean>
                <managed-bean-name>DSRApplication</managed-bean-name>
                <managed-bean-class>DSRApplication.LoginForm</managed-bean-class>
                <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
        <navigation-rule>
                <from-view-id>/DSR.jsp</from-view-id>
            <navigation-case>
                <from-action>#{DSRApplication.checkValidDateInAllFields}</from-action>
                <from-outcome>alldatasuccess</from-outcome>
                <to-view-id>/success.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-action>#{DSRApplication.checkValidDateInAllFields}</from-action>
                <from-outcome>datafail</from-outcome>
                <to-view-id>/fail.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>
    </faces-config>Thanks in advance to all.
    regards,
    Viswanadh.

    Thanks ejp for the reply.
    Since i am a beginner even i dont know the exact reason to answer you for why am i using JSP with Facelets.Kindly provide me the suggestion and valuable information you have so that i can learn.
    Apart from this i want to know whether the way provided in that faces-config.xml is possible or do we have a way to make that possible???
    regards,
    Viswanadh.

  • JSF Converter how to use property in faces-config

    I have made an Converter for my listbox, and it is working.
    Now I want to use a property to change the behavior of the converter.
    My faces-config looks like this:
    <!-- Converters -->     
    <converter>
    <converter-for class>model.PacemakerBranche</converter-for-class>
         <converter-class>cconverter.BrancheConverter</converter-class>
         <property>
              <property-name>test</property-name>
              <property-class>java.lang.String</property-class>
              <default-value>12345</default-value>
         </property>
    </converter>
    I try to set the test property to 12345.
    The setTest(String test) is not set.
    What am I doing wrong??
    My converter looks like this:
    public class BrancheConverter implements Converter {
    private String test;
    public String getTest() {
    System.out.println("getTest " + test);
    return test;
    public void setTest(String test) {
    System.out.println("setTest " + test);
    this.test = test;
    public Object getAsObject(FacesContext ctx, UIComponent component,
    String value) {
    return getMgr(ctx).getObject(model.PacemakerBranche.class, new Long(value));
    public String getAsString(FacesContext ctx, UIComponent component,
    Object object) {
    return ((BaseObject) object).getId().toString();
    private Manager getMgr(FacesContext ctx) throws HibernateException {
    return (Manager) FacesContextUtils.getWebApplicationContext(ctx).getBean("manager");
    }

    You can't use f:converter tag for setting properties.
    There are two ways you can use:
    (1) use f:attribute tag
    ex.<h:inputText value="#{...}"/>
      <f:converter converterId="...."/>
      <f:attribute name="test" value="#{...}"/>
    </h:inputText>Note that you should get the value of the attribute from the UIInput component, something like:comp.getAttributes.get("test");(2) develop a custom converter tag.

  • When To Use redirect/ In faces-config.xml

    In what situations should I use <redirect/> in faces-config. I understand what that using it causes it to generate a HTTP redirect instead of redirection through the view handler.
    I have ran into situations where if I don't use redirect, evein in a request scoped bean data isn't completely cleared out of a form. IE I have a list of users with a list of their addresses. If I look at an address on user 1 I see the right details, if I then move to user2 and look at one of his addresses it reflects the information from user1. As soon as I add <redirect/> the problem disappears.

    You normally use it to fire a brand new request.
    If I look at an address on user 1 I see the right details, if I then move to user2 and look at one of his addresses it reflects the information from user1. As soon as I add <redirect/> the problem disappears.This rather sounds like faulty code logic. Debug it.

  • Managed bean in both adfc-config.xml and faces-config.xml file

    hi,
    i can see that it's possible to declare managed bean in both adfc-config.xml and faces-config.xml file.
    is there any difference? which one is recommended?
    read here - http://www.jaypillai.com/tag/adf/
    but still not clear.
    thanks.

    Hi.
    As you know ADF is a framework based on JSF.
    In faces-config.xml you define general application manage beans. It offers you define manage beans for all application using JSF default scopes (application, session, request).
    In adfc-config.xml you define general application manage beans using ADF Scopes. It means that you can use JSF default ones including "view, pageFlow and backing".
    My recommendation is use only one point entry for your general manage beans. Use adfc-config.xml because allow you to use more scopes.
    Regards.

  • What belongs in the faces-config.xml file? Just bean and navigation info?

    I am looking for detailed information on the faces-config.xml file.
    I've used examples up to this point and I was wondering where the documentation for this configuration file was at.
    At this point, I know that bean management and navigation information is in this file, but are there other settings?
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Pringi: The tag explantion information, why isn't that easily found on Sun's web site or document site?
    This has been the most frustrating part - finding pieces of information here and there... and not in one location.
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Common Beans Faces Config (File Location)

    If you have a project with multiple JHeadstart App Definitions, what is the consequence of setting the 'Common Beans Faces Config' to a diffrent location for each App Def?
    e.g./WEB-INF/<subsystem>/JhsCommon-beans.xml
    Inside web.xml, javax.faces.CONFIG_FILES lists each of the separate JhsCommon-beans.xml files.
    I note that the help says this property should be set to the 'same across all application definition files'.
    JHeadstart 10.1.3

    Tom,
    1) On pressing find we notice the following (debug
    mode)
    -performs count hits query (e.g. 6 secs, a slow
    query!)
    -performs the main VO query with order by (again 6
    secs)
    -ripples through the label fetching (from bundles 3
    including jhs and javax)
    -once again, after the clear button label and before
    save button label (i.e. where table would be
    rendered), another count hits query (again 6 secs)
    total about 18 secs
    Any idea how to prevent the count hits (both)?Tom, I did the following: overwrite method getQueryHitCount in my ViewObjectImpl class, and set a breakpoint on the call to super. When I click find in a page, the method gets called through JhsSearchBean.executeAdvancedSearchBinding to determine whether any rows will be returned ro conditionally show the "Now Rows found"message, and whether the number of rows does not exceed the max number of query hits allowed.
    Then, if the query returns more rows than the rangeSize, the ADF Faces Table renderer calls the method again.
    So, I have either 1 or 2 calls to this method, not 3. The ADF Faces call canot be prevented, you could overwrite JhsSearchBean.executeAdvancedSearchBinding and remove the functionality that uses the getEstainmtaedRowCount call.
    To figure out why in your situation the method gets called 3 times, you can do the same as I did, overwrite getQueryHitCount and put a breakpoint on it.
    >
    2) For label fetching I note that the query labels
    are fetched twice (consequtively). Not sure what
    calls getMessage, but puzzled that it calls these
    labels twice, only once for the table column labels.This ADF Faces table rendering internals, nothing we can do about that.
    >
    3) One of the fields, FIND_STATUS is an
    af:selectOneChoice, with
    unselectedLabel="#{nls['UNSELECTED_LABEL']}", so this
    is translated.
    In addition the table has a field TABLE_STATUS, with
    same configuration.
    This second field as just displayed (not updateable),
    but if blank then the 'UNSELECTED_LABEL' translation
    is attempted for each row.
    Can JHeadstart control this to avoid this translate?
    i.e. the amount of translation is now row count and
    data dependent.Same as 20, This ADF Faces table rendering internals, nothing we can do about that.
    Steven Davelaar,
    JHeadstart Team.

  • Use TreeModel and MenuModel without Faces-Config

    I need to create a menu based off of data from a database. This data is in an hierarchical format, so it needs to be loaded into the TreeModel. I'm able to load the TreeModel from the persisted data; however, I now need to take that data and format it into the MenuModel so that I can use the menu ADF components (i.e. I don't want to use the ADF tree component). All the examples that I've seen that use the MenuModel involve setting up the menu items in the faces-config (e.g. #{menuItem_GlobalLogout}), which I cannot use.
    Is there a good example out there that shows how to load a MenuModel from a TreeModel without using the faces-config to setup the menu items?

    Hi,
    you should be able to adapt the sample to create your own menu model objects (nothing else is what the faces-config.xml version does. It just uses managed beans to have JSF instantiating the menu structure). So in your case you could use a table query to build and populate the query using Java objects similar to the provided sample.
    There is no sample available that I am aware of that shows how to do it differently though I once used the ADF tree binding to build the menu items
    Frank

  • How to update bean properties when using an immediate link

    Hello,
    I have a page with a find link next to an input text field. The input text field requires a valid code to be entered. If the user doesn't know the code they need to press the find link to go to a search page and select the code. The input text code field needs to have a value entered so it has its required attribute set because the validator I have and attached to the input text field does not get called unless something is entered in the field. If I don't set the link to immediate the required constraint prevents the search page from being invoked but if I do set it to immediate the values typed on the page are not updated to the bean properties they are bound to.
    I have read many posts but I fail to see a way to resolve this. The update model phase is apparently skipped because of the immediate attribute and so the values typed in by the user are lost.
    Please help.
    Thanks,
    Randall

    A UIInput holds the submitted value.
    When updating models it is cleared to null but when some error occurs it keeps to hold the submitted value.
    The TextRenderer uses the submitted value if the value is null.
    Therefore, you can see the submitted value is redrawn when some error occurs.
    Unfortunately, this mechanizm does not work beyond requests
    because the default application action listener always create a new viewroot based on the navigation rules.
    An general solution of your problem is not so easy.
    I think it may be to customize the action listener or the lifecycle.
    A temporal solution may be that the link action copys the submitted value to the managed-beans.

  • The Managed Bean in the faces-config.xml File

    I am still very new to JSF. I am confused about the managed bean.
    For example, I have a button in my web page. A click on this button invokes an action; say, ListAction.java.
    In this ListAction class, I instantiate a business delegate; say, ListPersonnel.java and call a method in this business delegate to return an ArrayList: personnel. Of course, this business delegate goes through facade, DAO, etc. to populate the ArrayList. This ArrayList is a collecation of a JavaBean called PersonnelBean that gets and sets a number of personnel information; such as ssn, name, etc.
    Upon this ArrayList is successfully populated and received by the ListAction class, I am going to display a web page with a table. In JSF, it is <h:dataTable ...>.
    My questions are regarding the managed bean in the faces-config.xml file.
    1. Which one is my <managed-bean-class>? packageName.ListAction? or packageName.PersonnelBean? or something else?
    2. What should be my <managed-bean-name>? I guess that I can give a name I like. Is it right? What about xyz?
    3. Then, how do I specify the "value" attribute of my <h:dataTable ...> tag when I display a web page to show the data table? Is it correct to specify value="#{xyz.personnel}"? What is the correct specification if it is wrong?
    4. I guess that I can give any name to the "var" attribute in the <h:dataTable ...> tag. Is it right?

    1. Which one is my <managed-bean-class>?
    packageName.ListAction? or
    packageName.PersonnelBean? or something else?ListAction
    2. What should be my <managed-bean-name>? I guess
    that I can give a name I like. Is it right? What
    about xyz?Anything you like. xyz is OK.
    3. Then, how do I specify the "value" attribute of my
    <h:dataTable ...> tag when I display a web page to
    show the data table? Is it correct to specify
    value="#{xyz.personnel}"? What is the correct
    specification if it is wrong?xyz.personnel is OK assuming that ListAction class has a public
    method getPersonnel() which returns the ArrayList of PersonnellBeans.
    4. I guess that I can give any name to the "var"
    attribute in the <h:dataTable ...> tag. Is it right?Yes, you can give any name you like.

  • Can I use morethen one faces-config.xml

    HI,
    now I am learning jsf, I have a doubt that ,can I use more than on faces-config.xml in one application ? and can we cahange name of faces-config.xml to faces-config-first.xml, and faces-config-second.xml? if it is possible , what should i do?
    Thank&Regards
    satya..

    Why would you want multiple config files? Is it for organization only...
    How would your app. know the when to use a different config file?
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                       

  • JSF Beta - faces-config.xml - Managed Bean Errors.

    I recently switched from EA4 to Realse Beta.
    When I start my web server, my app throws the following:
    Exception sending context initialized event to listener instance of class
    com.sun.faces.config.ConfigListener -- java.lang.NullPointerException
    I started removed stuff from my faces config and the application started up fine when I removed the managed beans that do not reference other managed beans(see below)?
    TIA,
    Juby
    Example
    <!-- =================== Managed Bean Facility ============== -->
    <managed-bean>
    <description>
    User Bean. This will hold the user info from ldap.
    </description>
    <managed-bean-name>levitonUserLdap</managed-bean-name>
    <managed-bean-class>leviton.ldap.Names</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    <managed-bean>
    <description>
    User Bean. This will hold the user info for the application.
    </description>
    <managed-bean-name>levitonUser</managed-bean-name>
    <managed-bean-class>leviton.FEOP.beans.User</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
    <property-name>firstName</property-name>
    <value-ref>levitonUserLdap.firstName</value-ref>
    </managed-property>
    <managed-property>
    <property-name>lastName</property-name>
    <value-ref>levitonUserLdap.lastName</value-ref>
    </managed-property>
    <managed-property>
    <property-name>domainUserId</property-name>
    <value-ref>levitonUserLdap.userId</value-ref>
    </managed-property>
    </managed-bean>

    I beileve this is the cuase of my error.
    Why did the <value-ref> tag get removed from the web-facesconfig_1_0.dtd?
    How can I reference another managed bean now?
    OLD web-facesconfig_1_0.dtd
    <!--
    The "managed-property" element represents an individual property of a
    managed bean that will be configured to the specified value (or value set)
    if the corresponding managed bean is automatically created.
    -->
    <!ELEMENT managed-property (description*, display-name*, icon*, property-name, property-class?, (map-entries|null-value|value|value-ref|values))>
    NEW web-facesconfig_1_0.dtd
    <!--
    The "managed-property" element represents an individual property of a
    managed bean that will be configured to the specified value (or value set)
    if the corresponding managed bean is automatically created.
    -->
    <!ELEMENT managed-property (description*, display-name*, icon*, property-name, property-class?, (map-entries|null-value|value|list-entries))>

Maybe you are looking for

  • Error while loading the delta to ODS

    Hi, I have an urgent situation. I am loading 500,000 records to my ODS with Delta request. All of them came to PSA and first 112,000 records got loaded and activated in ODS. Now, the request stays in yellow status. Other records have not loaded from

  • How to find out the Tcode related to a Script

    Hi All, Our client is using one ZFORM (on Bill Of Lading), How to find out, In which Tcode this particular Script was used? I have checked the TNAPR table, It's showing the Program Name Not Tcode. Any hint... Thanks, Kalyan

  • Discount in Services

    Hi, we have a business requirements like follows Vendor is providing Services to us , the price negociated with vendor is inclusive of MATERIAL and Services and payment will be made based on activity completion.For this we have created a service purc

  • Why does it take so long?

    Exporting Files from Final Cut Pro takes Forever. I imported a file that was a quicktime movie, .avi, and after just adding chapter marks, exporting it takes a real long time. I never fully wait it out because it takes too long. Is it because the fil

  • IMac - Where to buy replacement HD fan (Early 2009, 20") MB417LL/A

    The fan is old and worn out, and  I need a replacement HD fan! Where to buy replacement HD fan? Link? If I can I buy from Apple, link? Early 2009, 20" 2,66 Mhz, MB417LL/A?