JSF Method Binding

Hi everyone, I'm totally new to JSF and have been working on the examples by the James Holmes book, JSF Complete Ref:
http://www.jsfcompref.com/code_download.html
I have a question on MethodBinding managed beans.
In my faces-config.xml file I can specify a value for my currentYear.
  <managed-bean>
    <managed-bean-name>UserBean</managed-bean-name>
    <managed-bean-class>com.jsfcompref.register.UserBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
          <property-name>currentYear</property-name>
          <value>2007</value>
     </managed-property>
  </managed-bean>And I can retreive that as follows:
<h:inputText value="#{UserBean.currentYear}" required="true"
                              id="currentYear"/>That works, what I want to do is call a method from my faces-config file as such:
    <managed-property>
          <property-name>currentYear</property-name>
          <value>#{UserBean.someMethod}</value>
     </managed-property>But that returns an error
javax.faces.FacesException: Detected cyclic reference to managedBean UserBean...Any ideas what I'm doing wrong?

BalusC wrote:
You indeed cannot let the managed bean preinstantiate itself before setting any value in self. That would cause an infinite loop of managed bean creations, that's why this "cyclic reference" error is been thrown.
The only solution is to use the constructor for that instead:public UserBean() {
currentYear = someMethod();
Thank you Balus!! That was so easy it's scary :)

Similar Messages

  • Method Binding/ method call

    Hi
    I'm new to JSF and I have a problem understanding the Method Binding. I have a backing bean method which i want to be excecuted. I created a method binding like
    <t:tree dataSource="'#{Tree.configure}"/>
    My component extends UICommand and the action property is set correctly.
    But the Method configure() in class "Tree" is not excecuted. Maybe I understand something completely wrong with the method binding. Can anybody help me?
    Thanks in advance

    It is in fact a custom component
    My Tag-class
    public class JSFTreeTag extends UIComponentTag{
        public static final String RENDER_TYPE ="UITreeRenderer";
        public static final String COMPONENT_TYPE = "UITree";
        private String dataSource = "";
        private String immediate = "";
        /** Creates a new instance of JSFTreeTag */
        public JSFTreeTag() {
        public void setDataSource(String dataSource){
            this.dataSource = dataSource;
        public String getDataSource(){
            return this.dataSource;
        public void setImmediate(String immediate){
            this.immediate = immediate;
        protected void setProperties(UIComponent component){
            super.setProperties(component);
            UITree tree = null;
            try{
                tree = (UITree) component;
            }catch(ClassCastException cce){
                System.err.print("Component "+component.toString()+" is not of the expected type!");
            if (dataSource != null){
                if(isValueReference(dataSource)){
                   MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding(dataSource, null);
                   tree.setAction(mb);
                }else{
                    tree.getAttributes().put("dataSource", dataSource);
            if (immediate != null) {
                if (isValueReference(immediate)) {
                    ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(immediate);
                    tree.setValueBinding("immediate", vb);
                }else{
                     boolean _immediate = new Boolean(immediate).booleanValue();
                     tree.setImmediate(_immediate);
        public void release(){
            super.release();
            this.dataSource = null;
       public String getComponentType() {
            return COMPONENT_TYPE;
        public String getRendererType() {
            return RENDER_TYPE;
    }Component class
    public class UITree extends UICommand{
        public static final String FAMILY = "UITreeFamily";
        /** Creates a new instance of UITree */
        public UITree() {
        public Object saveState(FacesContext context){
            Object[] save = new Object[1];
            save [0] = super.saveState(context);
            return save;
        public void restoreState(FacesContext context, Object state){
            Object[] restore = (Object[]) state;
            super.restoreState(context, restore[0]);
        public String getFamily(){
            return FAMILY;
    }The component is not finished but debugger says that the action and iimmediate is set.
    tld
    <taglib xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
      version="2.0">
       <tlib-version>0.01</tlib-version>
      <tag>
           <name>jsftree</name>
                <tag-class>com.bla.bli.blubb.JSFTreeTag</tag-class>
           <attribute>
                <name>dataSource</name>
                <required>false</required>
                <rtexprvalue>false</rtexprvalue>
                <type>java.lang.String</type>
           </attribute>
            <attribute>
                <name>immediate</name>
                <required>false</required>
                <rtexprvalue>false</rtexprvalue>
                <type>java.lang.String</type>
            </attribute>
      </tag>
    </taglib>The renderer is not ready yet (just a code skeleton.
    I developed a custom component before so i have some (not much) experience but i have problems with the method binding

  • Method binding

    hi,
    i was trying to dynamically build a number of link buttons and associate them all using method binding to an action and this action is supposed to take as argument an ActionEvent object to detect what component triggered the action but when i run the code i always get an illegal agument exception,<br>
    <b>here is my code and the error ,wish any one could help<b>
    --------Code in backingBean--------------------
    Class[] signatures = {ActionEvent.class };
    MethodBinding mb1 = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{page2 .processAction}", signatures);
    mylink.setActionListener(mb1);
    public void processAction(ActionEvent ae) { .... }
    ---------------------End code-----------------
    The exception i get :
    Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
    Exception Details: java.lang.IllegalArgumentException argument type mismatch
    Possible Source of Error:
    Class Name: sun.reflect.NativeMethodAccessorImpl
    File Name: NativeMethodAccessorImpl.java
    Method Name: invoke0
    Line Number: -2
    Thanks in advance,
    sssnbj

    Can you try renaming your method to something else instead of processAction(). The default ActionListener also had processAction and so do other actionListeners. I am not sure if that would help but its worth trying. I don't see anything wrong with your code.
    Regards
    -Jayashri

  • Method Binding to JSF 1.0 validate-Method error

    Hi there,
    Iam impressed, changing from Beta to 1.0 wasn't that much work at all, I just got one problem left:
    <h:inputText value="#{methodsBean.orderNumber}" validator="#{methodsBean.checkOrderNumber}"/>
    This is my method:
         public void checkOrderNumber(FacesContext context, UIInput input, Object value) throws ValidatorException
              String orderNumber = (String)input.getValue();
              if (orderNumber.startsWith("100-") && orderNumber.length() == 8)
                   //ok
                   input.setValid(true);
              else
                   FacesMessage message =
                        new FacesMessage(
                             resources.getString("order_number_wrong"),
                             resources.getString("order_number_wrong_detail"));
                   throw new ValidatorException(message);               
    It does not work, but what's wrong? I
    any ideas?!
    Thanx!

    hi,
    perhaps you must use UIComponent instead of UIInput
    the signature of Validator.validate() changed.
    Object was added (you have it)
    and UIComponent instead of UIInput.
    here a method of me:
    public static void validateEmail(
              FacesContext context,
              UIComponent component,
              Object value)
              throws ValidatorException {
              if ((context == null) || (component == null)) {
                   throw new NullPointerException();
              if (!(component instanceof UIOutput)) {
                   return;
              String inhalt = value.toString();
                     //GenericValidator aus Commons-Validator-Projekt
              if (!GenericValidator.isEmail(inhalt)) {
                   FacesMessage fehler =
                        MessageFactory.getMessage(
                             context,
                             "EMAIL_UNGUELTIG",
                             new Object[] { "[email protected]" });
                   throw new ValidatorException(fehler);
         }cheers,

  • ADF JSF data binding: why state maintained between requests?

    Dear All,
    i want to know when and how the state of jsf can be maintain automatically by
    adf model.
    i have 2 pages, pageA.jspx and pageB.jspx. in pageA.jspx show some data in
    datatable (bound to methodIterator), when it go to pageB.jspx from pageA.jspx
    and then back to pageA.jspx, the state of the pageA.jspx seems can be stored
    by adf somewhere else.
    i.e. (pageA.jspx -> pageB.jspx -> pageA.jspx)
    ****all the backing beans are request scope.
    according to the adf dev guide, only the the page binding data for the current page will maintain automatically, then why when pageA.jspx's state is stored ?
    do adf store the state in session?? when can i rely on this nature to avoid reload
    pageA.jspx's data?? or how can i clear the state of pageA.jspx (blank page) (return from pageB.jspx)??
    the adf developer guide seems with little information about the page/binding data
    management..where can i found more information about this??
    thank you
    lsp

    Hi,
    i am using EJB + JSF + adf model.
    in this case its the iterator that survives the page navigationdo you mean that all iterator(method/variable..etc) can survive between page navigation??
    You can decide to refresh the iterator on each page load or re-execute the query if
    you don't want this.i want to 'clear' the iterator's data, but not to re-execute/refresh it to get data
    (as this will cause the underlying methodAction be executed once more)..i just want, say
    to display a 'blank' page, say blank pageA.jspx.
    IS THERE ANY REFENENCE document that describe the detail behavior..
    1. when state maintain?
    e.g. case 1 pageA->pageB->pageA->pageB (pageB's state maintained?)
    e.g. case 2 pageA->pageB->pageC->pageA (pageA's state maintained?)
    2. how do the state maintained??
    the iterators are stored in the session or store in the request (e.g. serialized in
    hidden input..etc)? will it lead to large memory usage in server side (until session
    end)?
    i can't find information about the state managementin
    the adf developer guide (not adf bc)..
    could you please point out where can i found these info??
    thank you.
    lsp
    Message was edited by:
    lsp
    Message was edited by:
    lsp
    Message was edited by:
    lsp

  • Web service method binding (flash builder issue)

    I have a new Flash Builder (Flex) project, basically it has 2 combo boxes in it. I have added a web service, the service is called uws_lookups and has 2 methods, lookupLanguage and lookupCountry.
    If I bind a combobox to the result from either of these services everything works as expected, here is the code:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:uws_lookups="services.uws_lookups.*"
          minWidth="955" minHeight="600">
    <fx:Script>
      <![CDATA[
       import com.adobe.serializers.utility.TypeUtility;
       import mx.controls.Alert;
       import mx.events.FlexEvent;
       protected function comboBox_creationCompleteHandler(event:FlexEvent):void
        lookupCountryResult.token = uws_lookups.lookupCountry();
      ]]>
    </fx:Script>
    <fx:Declarations>
      <s:CallResponder id="lookupCountryResult"/>
      <uws_lookups:Uws_lookups id="uws_lookups"
             fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
             showBusyCursor="true"/>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:ComboBox id="comboBox" creationComplete="comboBox_creationCompleteHandler(event)" labelField="countryName">
      <s:AsyncListView list="{TypeUtility.convertToCollection(lookupCountryResult.lastResult.Tables.Country.Rows)}"/>
    </s:ComboBox>
    <s:ComboBox/>
    </s:Application>
    As you can see the combobox gets bound, the results are returned and displayed, however when I bind the second box to the other method Flash Builder does the most stupid thing ever:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:uws_lookups="services.uws_lookups.*"
          minWidth="955" minHeight="600">
    <fx:Script>
      <![CDATA[
       import com.adobe.serializers.utility.TypeUtility;
       import mx.controls.Alert;
       import mx.events.FlexEvent;
       protected function comboBox_creationCompleteHandler(event:FlexEvent):void
        lookupCountryResult.token = uws_lookups.lookupCountry();
       protected function comboBox2_creationCompleteHandler(event:FlexEvent):void
        lookupLanguageResult.token = uws_lookups.lookupLanguage();
      ]]>
    </fx:Script>
    <fx:Declarations>
      <s:CallResponder id="lookupCountryResult"/>
      <s:CallResponder id="lookupLanguageResult"/>
      <uws_lookups:Uws_lookups id="uws_lookups" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:ComboBox id="comboBox" creationComplete="comboBox_creationCompleteHandler(event)" labelField="countryName">
      <s:AsyncListView list="{TypeUtility.convertToCollection(lookupCountryResult.lastResult.Tables.Country.Rows)}"/>
    </s:ComboBox>
    <s:ComboBox id="comboBox2" creationComplete="comboBox2_creationCompleteHandler(event)" labelField="LanguageName">
      <s:AsyncListView list="{TypeUtility.convertToCollection(lookupLanguageResult.lastResult.Tables.Country.Rows)}"/>
    </s:ComboBox>
    </s:Application>
    Now I'm pretty sure that isnt what I asked it to do, so I manually change the code line to read correctly
      <s:AsyncListView list="{TypeUtility.convertToCollection(lookupLanguageResult.lastResult.Tables.Language.Ro ws)}"/>
    Which enables to second combobox to work, but the original one (countries) now displays [Object: Language_type]
    I have debugged the application and both methods do actually return the correct data, FB is just choosing to do something stupid when I add the second call.
    I have done the basics, deleted the project and started again, tried a different web service, tried different methods, but it looks like when I use more than one method it fails, so please tell me, what am I doing wrong because I know Flash Builder cannot be doing this by design.
    I will post the service response in another post.
    Thanks for any help you have!
    Shaine

    Ok, lets prove I'm not going mad. New Project, add webservice, which has 2 methods as before. Drag datagrid to stage and bind to data for lookup countries, the code generated is:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:uws_lookups="services.uws_lookups.*"
          minWidth="955" minHeight="600">
    <fx:Script>
      <![CDATA[
       import com.adobe.serializers.utility.TypeUtility;
       import mx.controls.Alert;
       import mx.events.FlexEvent;
       protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
        lookupCountryResult.token = uws_lookups.lookupCountry();
      ]]>
    </fx:Script>
    <fx:Declarations>
      <s:CallResponder id="lookupCountryResult"/>
      <uws_lookups:Uws_lookups id="uws_lookups"
             fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
             showBusyCursor="true"/>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:DataGrid id="dataGrid" x="10" y="10" width="400" height="580"
        creationComplete="dataGrid_creationCompleteHandler(event)" requestedRowCount="4">
      <s:columns>
       <s:ArrayList>
        <s:GridColumn dataField="ID" headerText="ID"></s:GridColumn>
        <s:GridColumn dataField="countryName" headerText="countryName"></s:GridColumn>
       </s:ArrayList>
      </s:columns>
      <s:typicalItem>
       <fx:Object countryName="countryName1" ID="ID1"></fx:Object>
      </s:typicalItem>
      <s:AsyncListView list="{TypeUtility.convertToCollection(lookupCountryResult.lastResult.Tables.Country.Rows)}"/>
    </s:DataGrid>
    </s:Application>
    So. now te good bit, drag another datagrid to the stage and bind to the second method (languages), and guess what? it all goes horribly wrong, here is the complete code for that too:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:uws_lookups="services.uws_lookups.*"
          minWidth="955" minHeight="600">
    <fx:Script>
      <![CDATA[
       import com.adobe.serializers.utility.TypeUtility;
       import mx.controls.Alert;
       import mx.events.FlexEvent;
       protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
        lookupCountryResult.token = uws_lookups.lookupCountry();
       protected function dataGrid2_creationCompleteHandler(event:FlexEvent):void
        lookupLanguageResult.token = uws_lookups.lookupLanguage();
      ]]>
    </fx:Script>
    <fx:Declarations>
      <s:CallResponder id="lookupCountryResult"/>
      <uws_lookups:Uws_lookups id="uws_lookups"
             fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
             showBusyCursor="true"/>
      <s:CallResponder id="lookupLanguageResult"/>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:DataGrid id="dataGrid" x="10" y="10" width="400" height="580"
        creationComplete="dataGrid_creationCompleteHandler(event)" requestedRowCount="4">
      <s:columns>
       <s:ArrayList>
        <s:GridColumn dataField="ID" headerText="ID"></s:GridColumn>
        <s:GridColumn dataField="countryName" headerText="countryName"></s:GridColumn>
       </s:ArrayList>
      </s:columns>
      <s:typicalItem>
       <fx:Object countryName="countryName1" ID="ID1"></fx:Object>
      </s:typicalItem>
      <s:AsyncListView list="{TypeUtility.convertToCollection(lookupCountryResult.lastResult.Tables.Country.Rows)}"/>
    </s:DataGrid>
    <s:DataGrid id="dataGrid2" x="418" y="10" width="400" height="590"
        creationComplete="dataGrid2_creationCompleteHandler(event)" requestedRowCount="4">
      <s:columns>
       <s:ArrayList>
        <s:GridColumn dataField="ID" headerText="ID"></s:GridColumn>
        <s:GridColumn dataField="LanguageName" headerText="LanguageName"></s:GridColumn>
        <s:GridColumn dataField="LanguageCode" headerText="LanguageCode"></s:GridColumn>
       </s:ArrayList>
      </s:columns>
      <s:typicalItem>
       <fx:Object ID="ID1" LanguageCode="LanguageCode1" LanguageName="LanguageName1"></fx:Object>
      </s:typicalItem>
      <s:AsyncListView list="{TypeUtility.convertToCollection(lookupLanguageResult.lastResult.Tables.Country.Rows)}"/>
    </s:DataGrid>
    </s:Application>
    Now this is without ANY modification from me whatsoever, and all I get is the CountryID field displayed, so I modify the code manually to read:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:uws_lookups="services.uws_lookups.*"
          minWidth="955" minHeight="600">
    <fx:Script>
      <![CDATA[
       import com.adobe.serializers.utility.TypeUtility;
       import mx.controls.Alert;
       import mx.events.FlexEvent;
       protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
        lookupCountryResult.token = uws_lookups.lookupCountry();
       protected function dataGrid2_creationCompleteHandler(event:FlexEvent):void
        lookupLanguageResult.token = uws_lookups.lookupLanguage();
      ]]>
    </fx:Script>
    <fx:Declarations>
      <s:CallResponder id="lookupCountryResult"/>
      <uws_lookups:Uws_lookups id="uws_lookups"
             fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
             showBusyCursor="true"/>
      <s:CallResponder id="lookupLanguageResult"/>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:DataGrid id="dataGrid" x="10" y="10" width="400" height="580"
        creationComplete="dataGrid_creationCompleteHandler(event)" requestedRowCount="4">
      <s:columns>
       <s:ArrayList>
        <s:GridColumn dataField="ID" headerText="ID"></s:GridColumn>
        <s:GridColumn dataField="countryName" headerText="countryName"></s:GridColumn>
       </s:ArrayList>
      </s:columns>
      <s:typicalItem>
       <fx:Object countryName="countryName1" ID="ID1"></fx:Object>
      </s:typicalItem>
      <s:AsyncListView list="{TypeUtility.convertToCollection(lookupCountryResult.lastResult.Tables.Country.Rows)}"/>
    </s:DataGrid>
    <s:DataGrid id="dataGrid2" x="418" y="10" width="400" height="590"
        creationComplete="dataGrid2_creationCompleteHandler(event)" requestedRowCount="4">
      <s:columns>
       <s:ArrayList>
        <s:GridColumn dataField="ID" headerText="ID"></s:GridColumn>
        <s:GridColumn dataField="LanguageName" headerText="LanguageName"></s:GridColumn>
        <s:GridColumn dataField="LanguageCode" headerText="LanguageCode"></s:GridColumn>
       </s:ArrayList>
      </s:columns>
      <s:typicalItem>
       <fx:Object ID="ID1" LanguageCode="LanguageCode1" LanguageName="LanguageName1"></fx:Object>
      </s:typicalItem>
      <s:AsyncListView list="{TypeUtility.convertToCollection(lookupLanguageResult.lastResult.Tables.Language.Rows)}"/>
    </s:DataGrid>
    </s:Application>
    And now I can see the CountryID, LanguageID, LanguageName and LanguageCode, but still no Country Name, so where do I look now, and more to the point why is this happening?
    Please please please please help, this is just slightly more than business critical, I have to justify the cost of this project, and so far, not having  lot of fun with it.
    Thanks
    Shaine

  • Multiple Iterator for single Method Binding

    Hi,
    I have a POJO data control, which is exposing a method that is calling web service and fetching the data. The method has been added on the page as method action and created corresponding methodIterator. Now i want to create multiple tables based on the data set returned by the method but with different filter criteria. I tried using custom filterModel for this, it was working as well but data control method was getting called for each row populated in the table. This was causing Web Service call for each row.
    To avoid this, i created methods that are returning row sets to be populated in each tables in managed bean. Now i am trying to create MethodIterator based on these methods that will be referred by the table binding but its not working. How can i add these methods in managed bean as methodAction in my page definition file.
    Please let me know if there is any other way to achieve this. To summarize, i need to create multiple table with different filter criteria using one method that is returning complete data set using minimum service calls.
    JDev : 11.1.1.6.
    Thanks

    You don't understand. My JPanel implements the MouseListener interface and its mousePressed(MouseEvent ) method gets called THREE TIMES on a single mouse click. Normally it should only be called ONCE.
    It seems that the app that is using the JPanel extension has somehow registered it as interested in mouse events MULTIPLE TIMES.
    I've never seen this before in Swing and was wondering if anyone else has.
    Thanks,
    Ted

  • JSF: Method not being called

    Hi i've a problem that is grieving me. A method reference by a commandButton is not being called. Here's the code:
    JSP:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@page contentType="application/xhtml+xml"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <title></title>
    </head>
    <body bgcolor="white">
    <f:view>
            <f:loadBundle basename="sisard.maqueta.web.resources.ApplicationMessages" var="messages"/>
         <h:form id="newBookForm">
                <h2><h:outputText value="#{messages.welcomeMessage}" />:</h2>
                <h3><h:outputText value="#{messages.insertnewbook}" />:</h3>
                    <table>
                        <tr>
                            <td>
                                <h:outputText value="#{messages.code}" />:
                            </td>
                            <td>
                                <h:inputText id="code" value="#{GestionLibros.code}">
                                </h:inputText>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <h:outputText value="#{messages.example}" />:
                            </td>
                            <td>
                                <h:inputText id="example" value="#{GestionLibros.example}">
                                </h:inputText>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <h:outputText value="#{messages.title}" />:
                            </td>
                            <td>
                                <h:inputText id="title" value="#{GestionLibros.title}">
                                </h:inputText>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <h:outputText value="#{messages.yearpublication}" />:
                            </td>
                            <td>
                                <h:inputText id="datePublication" value="#{GestionLibros.datePublication}">
                                </h:inputText>                       
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <h:outputText value="#{messages.isbn}" />:
                            </td>
                            <td>
                                <h:inputText id="isbn" value="#{GestionLibros.isbn}">
                                </h:inputText>                       
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <h:outputText value="#{messages.cifeditorial}" />:
                            </td>
                            <td>
                                <h:inputText id="cifeditorial" value="#{GestionLibros.cifEditorial}">
                                </h:inputText>                       
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <h:outputText value="#{messages.nifautor}" />:
                            </td>
                            <td>
                                <h:inputText id="nifautor" value="#{GestionLibros.nifAutor}">
                                </h:inputText>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                            </td>                       
                        </tr>
                    </table>
                    <h:commandButton id="submit" action="#{GestionLibros.insertNewBook}" value="Inserir"/>               
            </h:form>
    </f:view>
    </body>
    </html>The backing bean:
    package sisard.maqueta.web.cases.case01.view;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.GregorianCalendar;
    import sisard.maqueta.sgl.model.exception.SGLException;
    import sisard.maqueta.sgs.model.exception.StockException;
    import sisard.maqueta.web.com.SGLManagedBean;
    import sisard.maqueta.web.com.ExceptionUtil;
    import sisard.maqueta.web.factory.DelegateFactory;
    public class GestionLibroManagedBean extends SGLManagedBean{
        private String code;
        private Long example;
        private String title;
        private Calendar datePublication;
        private String isbn;
        private String cifEditorial;
        private String nifAutor;
        public GestionLibroManagedBean() {
        public String insertNewBook() throws SGLException, StockException,
                                             Exception {
            DelegateFactory.getInstance().getLibroDelegate().insertarLibro(
                code,
                example,
                datePublication,
                isbn,
                title,
                cifEditorial,
                nifAutor);
                return "showBooksFound";
        public void setCode(String code) {
            this.code = code;
        public String getCode() {
            return code;
        public void setExample(Long example) {
            this.example = example;
        public Long getExample() {
            return example;
        public void setTitle(String title) {
            this.title = title;
        public String getTitle() {
            return title;
        public void setDatePublication(Date datePublication) {
            Calendar gregorianCalendar = new GregorianCalendar();
            gregorianCalendar.setTimeInMillis(datePublication.getTime());
            this.datePublication = gregorianCalendar;
        public Date getDatePublication() {
            return datePublication != null ? datePublication.getTime() : null;
        public void setIsbn(String isbn) {
            this.isbn = isbn;
        public String getIsbn() {
            return isbn;
        public void setCifEditorial(String cifEditorial) {
            this.cifEditorial = cifEditorial;
        public String getCifEditorial() {
            return cifEditorial;
        public void setNifAutor(String nifAutor) {
            this.nifAutor = nifAutor;
        public String getNifAutor() {
            return nifAutor;
    }faces-config.xml
    <?xml version="1.0" encoding="windows-1252"?>
    <!DOCTYPE faces-config PUBLIC
      "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
      "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config xmlns="http://java.sun.com/JSF/Configuration">
      <!-- ##################################################### -->
      <!-- MANAGED BEANS CASO DE USO 01- LIBROS -->
      <!-- ##################################################### -->
      <managed-bean>
        <managed-bean-name>BuscarLibros</managed-bean-name>
        <managed-bean-class>sisard.maqueta.web.cases.case01.view.BuscarLibroManagedBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>
      <managed-bean>
        <managed-bean-name>GestionLibros</managed-bean-name>
        <managed-bean-class>sisard.maqueta.web.cases.case01.view.GestionLibroManagedBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>
        <!-- ######################################## -->
        <!-- NAVIGATION RULES CASO DE USO A01-DATOS ADMINISTRATIVOS DE USUARIO -->
        <!-- ####################################################### -->
        <navigation-rule>
            <from-view-id>/searchBooks.jsp</from-view-id>
            <navigation-case>
                <from-outcome>showBooksFound</from-outcome>
                <to-view-id>/searchBooks.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>insertNewBook</from-outcome>
                <to-view-id>/insertNewBook.jsp</to-view-id>
            </navigation-case>       
        </navigation-rule>
        <navigation-rule>
            <from-view-id>/insertNewBook.jsp</from-view-id>
            <navigation-case>
                <from-outcome>showBooksFound</from-outcome>
                <to-view-id>/searchBooks.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>   
    </faces-config>Thanks in advance.

    Thanks for your reply. The problem was with Date datePublicacion. It was missing a converter.
    java.util.Date is deprecated. Is there a chance to use java.util.Calendar?

  • Little help about jsf method. . .

    please, could you give me a tip? This method below returns me a object mapped in the faces-config.xml file as "exemple" , am I right?
    thanks.
    FacesContext.getCurrentInstance().getApplication().createValueBinding("#{exemple}").getValue();

    yes

  • Component binding - changes are not reflected

    Dear all,
    When using JSF method binding I'm experiencing the following strange behavior.
    Within the view, I'm registering a panel by method binding expression, which I then use within the controller bean to add additional UIComponents on it. However when running through "addTestToDEBUG()", the existing Panel is retrieved properly via the getViewRoot's children, the new HtmlOutputText is created and added upon - also when I call getComponent on the newly created HtmlOutputText's userID I get the UIComponent returned.
    However after the addTestToDEBUG() method has finished and the view is updated, the "setComponentPanelDEBUG(UIComponent panel)" is called, but panel (where we have added child UIComponents upon, does not contain the HtmlOutputText element!
    Where's my conceptional error? Thanks for your help!
    Please find attached my sample code:
    here's my view:
    <h:form id="formXmlDebugTemplate">
         <p><h:outputText value="Debugging:"/></p>
         <h:panelGroup id="panelDEBUG" binding="#{RegisterTBServiceBean.componentPanelDEBUG}">               </h:panelGroup>
         <br/>  
          <h:commandButton id="buttonDEBUG" value="Add Element" action="#{RegisterTBServiceBean.command_addDEBUGITEM}"/>     
    </h:form>here's the bean:
    private UIComponent debug = new UIPanel();
    public UIComponent getComponentPanelDEBUG(){
         return this.debug;
    public void setComponentPanelDEBUG(UIComponent panel){
         this.debug = panel;
    }here's the controller
    public void addTestToDEBUG(){
         UIComponent panel = (UIComponent)getComponent("formXmlDebugTemplate:panelDEBUG");
         String sRandom = ((int)((java.lang.Math.random()*100)))+"";
         facesContext = FacesContext.getCurrentInstance();
         HtmlOutputText outputText = (HtmlOutputText) facesContext.getApplication().createComponent(HtmlOutputText.COMPONENT_TYPE);
         outputText.setValue("Test"+sRandom);
         outputText.setId("xmlDEBUGOutputText"+sRandom);
         panel.getChildren().add(outputText);          
    private UIComponent getComponent(String sID){
         facesContext = FacesContext.getCurrentInstance();
         Iterator<UIComponentBase> it = facesContext.getViewRoot().getChildren().iterator();
         UIComponent returnComp = null;
         while(it.hasNext()){
              UIComponent guiComponent = it.next().findComponent(sID);
              if(guiComponent!=null){
                   returnComp = guiComponent;
         return returnComp;
    }

    Dear all, thanks for your help - we've finally found what was causing the problems:
    So the behaviour was that actually all "method bound" UIComponents were updated within the bean, but the changes were not reflected within the gui.
    Well *<redirect>* within the faces-config was causing the problems
    Redirect foces a HTTP redirect instead of using the usual ViewHandler mechanism to take place.
    kr A.

  • JSF Declarative Component - Using a method?

    Hello. I'm creating a declarative component that has a submit button. I want the submit button to be defined, but I want the person using the component to define the action (ex, they specify which method from an AM to execute) How can I do this? I tried defining a method and setting the buttons action to comp.whatever. However, when the person defines the button and points the method to the binding layer, it can never located the method.
    Thanks, Graeme.

    Hi Shay, thanks for the response. I have read the tutorial. The only difference is in the tutorial it's executing a method on the view object. I need to execute a method on my application module. I defined it on my declarative component as:
    <af:commandButton text="commandButton 1" id="dc_cb1"
    actionListener="#{comp.submitRegistrationForm}"/>
    As this kind of method attribute
    <method-attribute>
    <attribute-name>
    submitRegistrationForm
    </attribute-name>
    <method-signature>
    void submitRegistrationForm(oracle.jbo.ViewObject)
    </method-signature>
    <required>
    false
    </required>
    </method-attribute>
    Then I dragged in my custom component and defined my submit button as #{bindings.sendRegistration.execute} The sendRegistration is a method in my AM. I created a method binding for this as
    <methodAction id="sendRegistration"
    InstanceName="RegistrationAMDataControl.dataProvider"
    DataControl="RegistrationAMDataControl"
    RequiresUpdateModel="true" Action="invokeMethod"
    MethodName="sendRegistration" IsViewObjectMethod="false"
    ReturnName="RegistrationAMDataControl.methodResults.sendRegistration_RegistrationAMDataControl_dataProvider_sendRegistration_result">
    <NamedData NDName="vo" NDValue="#{bindings.FirstName.attributeValue}"
    NDType="oracle.jbo.ViewObject"/>
    </methodAction>
    However, everytime I hit the button I get an error the method does not exist. Method not found: UserRegistrationFormComponent[oracle.adf.view.rich.component.fragment.UIXInclude$ContextualFacesBeanWrapper@1572ca2, id=urf1].SubmitRegistrationForm(javax.faces.event.ActionEvent)
    Is it possible to call this to my AM?
    Thanks.

  • ADF Groovy Expression with bind variable and ResourceBundle

    Now I have ViewObject which have WHERE clause with bind variable.
    This bind variable is for language. Within bind variable I can change Value Type to Expression and into Value: I put +(ResourceBundle.getBundle("model.ModelBundle")).getString("language")+.
    Now if I run Oracle Business Component Browser (on AppModule) this works. In my ModelBundle.properties there is language=1 name-value pair. And with different locale I have different language number.
    Now if I put that ViewObject on one JSF, this bind variable expression does not work any more. Error:
    *oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.util.MissingResourceException, msg=Can't find bundle for base name model.ModelBundle, locale my_locale*
    Any ideas?
    10x
    Zmeda

    The most wierd thing is that, if I make ViewObjectImpl and insert this method
    public String getLanguage() {
    return (ResourceBundle.getBundle("model.ModelBundle")).getString("language");
    and call it in Bind Variable Expression Value: viewObject.getLanguage()
    IT WORKS!
    But why with groovy expression it does not work?
    Zmeda

  • How to Use another JSF page that I load by XMLHttpRequest?

    Hi everyone, I'm a newbie of JSF and curisous about how to load page content seperately by AJAX.
    I saw example of Java Blue Print. It's load some data to use in page. What I want is to load another JSF page when click a link or button, (Like include another page). And work with functions privoided by loaded JSF Page.
    My example is, In a main page. I request a JSF page and set it into a div layer.
    var requestURL = "/admin/customer/customer-list-body.faces";
    var content = postDataWithoutContent(requestURL);     divContent.innerHTML = content;     
    All JSF components are required under <f:view>, thus action of form is set as "action='"/admin/customer/customer-list-body.faces'"
    But my page is main.jsp. Each time I click command button in customer-list-body.faces, the url will change to customer-list-body.faces, I want to request and hold in main.jsp.
    What can I do then? Any advices?

    Hi,
    the list doesn't seem to be your problem. You need to track down the illegal argument exception. Once you have that sorted out, expose the method on the AM so it gets shown as a method binding. The return values then could be picked up in a managed bean to create the select Item list
    Frank

  • How to bind a complex object to a composite component

    I'm using JSF2 and having an issue binding an object (EL Expression) as a parameter to my composite component.
    I have written a composite component (not very complex) that will display a drop-down list of countries and should bind the selection to a provided target bean.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:composite="http://java.sun.com/jsf/composite"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
    <!-- INTERFACE -->
    <composite:interface>
    <composite:attribute name="label" required="true" />
    <composite:attribute name="requiredMessage" required="true"/>
    <composite:attribute name="target" required="true" type="com.mycompany.entity.Country"/>
    </composite:interface>
    <!-- IMPLEMENATION -->
    <composite:implementation>
    <h:panelGrid columns="2">
    <h:outputLabel for="country-list" value="#{cc.attrs.label}"/>
    <h:panelGrid id="country" columns="1" styleClass="select-one-menu-panel" >
    <h:selectOneMenu id="country-list"
    enabledClass="select-one-menu-enabled" disabledClass="select-one-menu-disabled"
    layout="pageDirection"
    value="#{cc.attrs.target}"
    required="true" requiredMessage="#{cc.attrs.requiredMessage}"
    >
    <f:selectItem itemLabel="#{msgs['label.pleaseSelect']}" itemValue="" />
    <f:selectItems value="#{countryController.countries}" />
    <a4j:ajax />
    </h:selectOneMenu>
    <a4j:outputPanel id="country-list-error-panel" ajaxRendered="true">
    <h:message id="country-list-error" for="country-list" style="color:red"/>
    </a4j:outputPanel>
    </h:panelGrid>
    </h:panelGrid>
    </composite:implementation>
    </html>
    I want to be able to use the composite component in the following way:
    <util:country-select
    label="#{msgs['label.countryOfBirth']}"
    requiredMessge="#{msgs['error.birthCountryRequired']}"
    target="#{participant.countryOfBirth}"/>
    When I load the page everything renders correctly, but when I select an item from the drop-down I get a validation error.
    apply-form:j_idt77:country-list: Validation Error: Value is not valid
    I know that it must be something with the way that I have the parameters defined but I simply can't find any information to help me figure this out.
    Any light that you might be able to she on this would be greatly appreciated.
    Thank you for the help...

    Hi,
    well, you can. What the ADF Data Control and thus the binding gives you is the JSF component binding and the business service access.
    If you don't want to use ADF, then what you can do is
    - Create an ADF BC root Application Module from a managed bean
    e.g. see http://docs.oracle.com/cd/E21764_01/web.1111/b31974/bcservices.htm#CHDDDBFC
    - Access the View Object for querying the data to display
    - Expose the queried data so the component can handle it e.g. setter/getter for input components, ArrayList for tables (or you create the more complex component models like table and tree models)
    Having outlined the above, here are some gotchas to watch out for
    - Make sure creating the root application module is done such that you don't create/release it with each request. So you may consider a data serving managed bean in a scope like page flow or session
    - Ensure you have helper methods that allow you to query and CRUD operate the View Object data
    Frank

  • What is the best way to Process non-JSF request??

    I am engaged in new project using JSF.
    We came across the serious problem that there is no-way
    to let JSF execute action method of managed bean at the
    first request.
    That is because, JSF gets method binding information only
    from pre-displayed UIComponent, it seems impossible to
    let JSF know about the method binding info when they receive
    the request from external system, or from non-JSF pages i n the
    same system.
    I get to two ways to solve this problem.
    1. develop a custom-servlet
    The tasks of the custom servlet is,
    - receive a request from external system or non-JSF pages.
    - get managed bean and execute it's action method.
    - get next page info
    - dispatch to next page through FacesServlet
    2. use bridge-JSF page as a intermediation
    This is kind of last resort.
    As I described above, JSF can get method binding info, only
    from components of pre-displayed pages.
    So, I use bridge -JSF page to let it work as a intermediation.
    It displays nothing, just click the commandbutton automatica
    lly(by JavaScript).
    Of-cource, I prefer 1 to 2.
    Codes below are custom servlet sample , I made.
    Pls let me know if it's ok or not.
    thanks
    public class FESFacesServlet extends HttpServlet{
        public void doPost(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
    /* init process */
            LifecycleFactory lFactory = (LifecycleFactory)
                                            FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
            Lifecycle lifecycle = lFactory
                                    .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
            FacesContextFactory fcFactory = (FacesContextFactory)
                                                FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
            FacesContext facesContext = fcFactory.getFacesContext(getServletContext(), request, response,lifecycle);
            Application application = facesContext.getApplication();
    /* set from-view-id */
            ViewHandler viewHandler = application.getViewHandler();
            String viewId = request.getParameter("fromviewid");
            UIViewRoot view = viewHandler.createView(facesContext, viewId);
            facesContext.setViewRoot(view);
    /* find managed bean and execute it's action method */
            ManagedBeanBase managedBean = (ManagedBeanBase)application.getVariableResolver().
                                                    resolveVariable(facesContext, request.getParameter("command"));
            String outCome = managedBean.start();
    /* look for next page info */
            NavigationHandler navigationHandler = application.getNavigationHandler();
            navigationHandler.handleNavigation(facesContext, null, outCome);
    /* dispatch to next page throw FacesServlet */    
            facesContext.getExternalContext().dispatch("/faces" + facesContext.getViewRoot().getViewId());
            facesContext.release();
        public void doGet(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
            this.doPost(request,response);
    -

    the common approach is kind of like your number 2)
    but you dont need a commandButton
    just have your first page redirect to your start page
    e.g.
    index.html
    <html>
    <head>
    <!�redirect to startPage -->
    <meta http-equiv="Refresh" content= "0; URL=index.faces"/>
    <title>Start Web Application</title>
    </head>
    <body>
    <p>Please wait for the web application to start.</p>
    </body>
    </html>

Maybe you are looking for

  • Does Delivered mean the person is on or it just sent?

    I'm seriously wondering when i send a message to my friend they don't have read receipts. Sometimes it will quickly say Delivered and others it takes a little bit. Does it mean they're on their phone when it automatically says delivered or did it jus

  • Activity type price report

    Pls advice a Activity type price report to get full fiscal years ( 12 period ) activity prices at one for all the activity type. We need of doing the comparison but in KSBT it gives only one period value at once. Thanx

  • Jdeveloper plugin for jd edwards

    Hi, while reading docs about new features in jde tool 8.97, I've found that there is plugin in jdev for creating business services for jde, but no refs on itself. where I can get. No, I've not found it on peolpesoft.com

  • Customization of PROJECT BUDGET ACCOUNT GENERATOR

    Hi Anyone customized project budget account generator. Please breif how to configure the workflow as it creates accounts for budget lines How this workflow is triggered and what are the attributes top_tak_number and low_task_number. I need to develop

  • Corrupt databook.dat without palm OS

    Dear, I used to have a Palm III , but when it broke down, I continued to use the agena (databook) since I find it easy to use. My last .bak file is of 2001, so I assume then my palm device died. However, now the database file (databook.dat) crashed.