Component binding and Value change listeners

Hi -
I'm fairly new to JSF and are having a few teething problems.
I have a date component in my registration page. Its made of up 3 text inputs (1 each for day, month, year). Since these need to be validated as a group I use a method in my backing bean (request scoped) to do this. (I saw this demonstrated in Core JSF).
Here's my code for the date components:
<h:outputLabel value="#{register.labelData.dateOfBirth}" /><br />
<h:message for="day" styleClass="error" />
<h:inputText id="year" styleClass="input smaller" maxlength="4" value="#{register.dateOfBirthYear}" binding="#{register.dobYearInput}" onfocus="doOnFocus('registerForm:year')" onblur="doOnBlur('registerForm:year')" tabindex="12" />
<h:inputText id="month" styleClass="input smallest" maxlength="2" value="#{register.dateOfBirthMonth}" binding="#{register.dobMonthInput}" onfocus="doOnFocus('registerForm:month')" onblur="doOnBlur('registerForm:month')" tabindex="13" />
<h:inputText id="day" styleClass="input smallest" maxlength="2"  value="#{register.dateOfBirthDay}" binding="#{register.dobDayInput}" validator="#{register.validateDate}" required="true" requiredMessage="#{register.msgData.dobMandatory}" onfocus="doOnFocus('registerForm:day')" onblur="doOnBlur('registerForm:day')" tabindex="14" />Now this works great.
The other feature I have on the page is a select box so the page can be displayed in different languages. My application stores the current language in a session scoped bean. I have attached a value change listener onto the select box so the session is updated with the new language.
<h:outputLabel for="languageSwitch" value="#{sessionBean.labelData.langSwitch}" />
<h:selectOneMenu id="languageSwitch" styleClass="select" onchange="submit()" immediate="true" value="#{sessionBean.language}" valueChangeListener="#{sessionBean.changeLanguage}">
    <f:selectItems value="#{sessionBean.languages}" />
</h:selectOneMenu>The request scoped beans have a reference to this session scoped bean, and use it to look up the page text in the appropriate language from the DB. IE:
String label = getMessage(getSession().getLocale());The problem is on the registration page - because the date controls are bound to the managed bean the bean is (re-)created in the RESTORE_VIEW phase, BEFORE the value in the session has been update in the PROCESS_VALIDATIONS phase.
I'm a little puzzled as to how berst to fix this problem - so any ideas that anyone has would be gratefully received.
Thanks -
Edited by: mbea023 on Jul 20, 2008 9:18 PM

Thanks for the reply Raymond -
The request scoped beans don't actually store the Locale directly - they have a reference to the SessionBean which store the locale. So they determine the locale by the following:
Locale currentLocale = getSessionBean().getLocale();The reference to the SessionBean is injected (by Spring) in the constructor of the request scoped bean. Then, in the constructor, the request bean queries the DB for the language specific text to display on the page. EG:
public MyRequestScopedBean {
String message = messageAccessor.getMessage(messageKey, currentLocale);
}Unfortunately it is a requirement to use a DB to store messages, so we can't use resource-bundles.
Firstly, Is this the best way of request scoped beans having a reference to the session? Or is there a better way.
The problem occurs when I have a page that has control bound to the request scoped bean ie:
<h:XXXX binding="myRequestBean.ZZZ />
{code}
Then the constructor of the request bean runs *before* the value of the locale is changed in the sessionBean - this means the page messages are looked up with the old locale.
Any further advice would be a great help - Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Component binding and state saving

    Hello,
    I have a few questions in regards to component binding and state saving (specifically in regards to the reference implementation) when the saving method is client and backing-beans are in the request scope rather than in the session scope:
    1) if a component instance is bound to a backing-bean property then does the state of that component get saved when the view state is saved?
    2) for UIData component, if the component value is bound to a list, does the actual list (after being wrapped) serve as the local data for the component? If this is the case, when the state is saved and then subsequently restored, does the list get re-created with the original number of items?
    Regards,
    Len Takeuchi

    Thanks for the quick response.
    (2) The actual list is not saved; the list will be
    re-queried on subsequent requests.The list composition may have changed by the time the list is re-queried. If the table being displayed is updatable then transfer of information from request back to the list (during Apply Request Values) may not happen properly. So does that pretty much mean that the original list has to be kept around (in the session)? If the state saving method is server then does the saved state maintain a reference to the original list across requests?
    Len Takeuchi

  • Difference between using Binding and Value Attribute

    what is the deference between using binding and value attribute, when I use binding attribute at the time of Value change listener is behaving like action listener,
    Ex:
    If I use value attribute, at the time of value change listener the component is not showing the result in the component but when I use Binding attribute it is happening automatically. So I want to know how the binding attribute is working.
    I know, at the time of binding attribute the component is creating an instance at the bean side, So even also how it is following the life cycle of the JSF Frame work, and also Please suggest me weather which one is better to use either Binding or Value?

    JNaveen wrote:
    If I use value attribute, at the time of value change listener the component is not showing the result in the component but when I use Binding attribute it is happening automatically. So I want to know how the binding attribute is working.You need to learn about the JSF lifecycle. The ValueChangeEvent is invoked after conversion and validation in the 3rd phase, while the model values are updated in the 4th phase. In the valueChangeListener method you normally use ValueChangeEvent#getNewValue() to get the new value after the change.
    I know, at the time of binding attribute the component is creating an instance at the bean side, So even also how it is following the life cycle of the JSF Frame work, and also Please suggest me weather which one is better to use either Binding or Value?Use the 'value' attribute to bind the value to the bean. Use the 'binding' attribute to bind the component to the bean. If you don't need to precreate the component or do other things than getting/setting its value, then there is no need for the 'binding' attribute.
    Read on those links if you want to know something more about the JSF lifecycle:
    [http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html].
    [http://jcp.org/aboutJava/communityprocess/final/jsr252/index.html] (pick 1st download).

  • Difference between binding and value

    Hi
    I am new to JSF
    Can you tell me what is the difference between binding and value attribute of a
    JSF component ?
    Many thanks.

    Hi,
    the binding is the component association to a managed bean (or backing bean). This allows you to manipulate the component in Java code stored in a managed bean.
    The value is what the actual component value is.
    Frank

  • If I consider heap size, should I follow component binding or Value binding

    Hi,
    I have an Web application my pages gets change rapidly in run time(components get disable and invisible at run-time depends on user input), So in that case which kind of binding approach I have to follow if I consider Heap memory of run time.

    navaneeth.j wrote:
    I am getting more grip on the component means, in ValueChange event I can get the updated value in the backing bean, That means on the updated values of the rest of the components are not available only we can get evt.getNewValue for event produced component. Example there are 5 components in the page if the event got generated from the 3rd component so in that valuechange event method needs the first two components values also. In value binding I can't get those value but in the component binding every component's updated value I can get.That's why I mentioned AJAX enabling the view in the previous post.
    I can accept for 3rd party libraries if we use value binding it would be very easy to detach and use another one but for basic components I am not able to visualize the need to use the other >API, If my guess is right, for look and feel purpose means we can change the renderkit na.
    Please suggest me am I thinking in the right direction or notRichfaces, Tomahawk and many others have lots of components that solve common problems that you are going to meet when using plain JSF components.
    Yes people try to stick to standard JSF as much as possible but it is not always possible nor always beneficial.
    Like I said it's not hard and fast. As long as you understand the advantages and disadvantages of each technique so that you can chose the correct approach according to requirements.
    The memory differences are unlikely to impact in a major way.

  • Drop Down Lists and Value Change Events

    I have 4 drop down lists each with a set of values from the database.
    Based on the value of the first list(ValueChangeEvent only for list1) , I fetch data from the database and set the 'selected value' in the other lists.
    I have a Submit button which takes values from these 4 lists and puts it in the database.
    Problem:
    I change list 2 through list 4 and hit a Submit button which inserts all the values in the database.
    However,on Clicking the Submit button I never get the new selected values, it always refers to the previously fetched values.
    I tried to recreate this case in a Sandbox without a database , Here is the code:
    Page1.jsp
    <h:selectOneMenu id="list1" value="#{SessionBean1.selectedList1}" valueChangeListener="#{SessionBean1.list1ValueChangeListener}"  onchange="this.form.submit();" >
                   <f:selectItems id="dropdown1SelectItems" value="#{SessionBean1.list1}"/>
    </h:selectOneMenu>
      <h:selectOneMenu id="list2" value="#{SessionBean1.selectedList2}" >                           
                  <f:selectItems id="dropdown2SelectItems" value="#{SessionBean1.list2}"/>
       </h:selectOneMenu>
       <h:commandButton id="add" actionListener="#{SessionBean1.addActionListener}" value="Add"/>
        <h:inputText id="result" value="#{SessionBean1.result}" />SessionBean1
       public SessionBean1() {
            list1.add(new SelectItem("0","0"));
            list1.add(new SelectItem("1","1"));
            list1.add(new SelectItem("2","2"));
            list1.add(new SelectItem("3","3"));
            list2.add(new SelectItem("a","a"));
            list2.add(new SelectItem("b","b"));
            list2.add(new SelectItem("c","c"));
            list2.add(new SelectItem("d","d"));
            map.put("0", "a");
            map.put("1", "b");
            map.put("2", "c");
            map.put("3", "d");
        private void fetch_data(String value){
             selectedList2=map.get(value);
        public void list1ValueChangeListener(ValueChangeEvent vce){
                fetch_data(vce.getNewValue().toString());
        public void addActionListener(ActionEvent event){
            result=selectedList2;
        }I tried debugging and found that after the Value Change Event is fired only selectedList1 gets a new value during Update Model Values Phase and selectedList2 still has the old value.
    With this sand box project I cannot even get the second list to show the corresponding value.
    Any insight on this would be helpful

    Thank You Balus C,
    I just realized the reason why this is not working, I found the reason in your article Populating Child Menu's article, I am just
    putting it as a reference here.
    One concern is that the skipping of the UPDATE_MODEL_VALUES will also cause that the new values of the menu's which have immediate="true" set won't be set in the backing bean. This can partly be fixed by getting the new value from the ValueChangeEvent inside the valueChangeListener method and assign it to the appropriate property. But this won't work for other menu's of which the valueChangeListener isn't been invoked. This would cause problems if you select a child menu value and then select the parent menu back to null and then reselect it to same value again, the child menu which will show up again would remain the same selection instead of null while its child will not be rendered! To solve this we need to bind the menu's to the backing bean so that we can use UIInput#setValue() and UIInput#getValue() to set and get the actual values.+ The JSF lifecycle will set and get them in the RESTORE_VIEW and RENDER_RESPONSE phases respectively.+
    I am not sure I understand whether or not it is a limitation but the reason above is valid and I rolled back to binding my menus and getting to work with that.
    Is Binding UI components a wise idea because most of the attributes can be programmed using properties in Backing Beans unless you have to build new components?
    Thanks Again

  • OutputText : why both bind and value attribute and other gripes

    Hi
    gripe1
    I have started using creator and I'm a bit confused as to why creator insists on the binding attribute being in place to link the outputText field to the default managed bean -
    like most of us I want to set the value via a resource bundle. ( as shown blelow). If I delete the binding atttribute then outputText Field doesn't get displayed in the Visual Design tab. aaaaaaah!
    <h:outputText binding="#{DemographicInformation.nameLabel}" id="nameLabel" value="#{bundle.userName_label}"/>
    gripe2
    When you declare a resource bundle; either through editing the source directly or dragging from the advanced palette you can't seem to be able place the contained "names" in this the individual outputText field values via value property->bind to object->select from property file. i.e you do don't see to be able to expand the f: loadBundle. This results in a lot of tedious typing
    which I thought this tool was all about preventing!
    Regards
    Daniel

    Re gripe 1:
    Why do you want to remove the binding attribute? The binding attribute has nothing to do with the value - you can certainly display values from resource files without removing the binding attribute. One of the online tutorials (the Sign On example) shows a Creator project using bundle files.
    Re gripe 2:
    The designtime experience for using bundle files in the web app has been improved in the next version of Creator.
    -- Tor
    http://blogs.sun.com/tor

  • Differentiating HTTP Request through a URL and a value change listener

    Version Details:
    Oracle JDeveloper 11g Release 1 11.1.1.4.0
    Studio Edition Version 11.1.1.4.0
    Build JDEVADF_11.1.1.4.0_GENERIC_101227.1736.5923
    IDE Version: 11.1.1.4.37.59.23
    Product ID: oracle.jdeveloper
    Product Version: 11.1.1.4.37.59.23
    ADF Business Components     11.1.1.59.23
    Java(TM) Platform     1.6.0_21
    Oracle IDE     11.1.1.4.37.59.23
    Versioning Support     11.1.1.4.37.59.23
    Base Details:
    The Product, that a different team is working on (<i><b>which I cannot access, code, touch,...</b></i>), creates reports and essentially generates a URL with a bunch of parameters:
    http://<host>:<port>/myApplication/main.jspx?parameter1=value1&parameter2=value2...When the user clicks on an "Edit" button, a modal popup window is displayed (using jQuery) with an embedded iFrame with its source pointing to the above URL.
    The "myApplication" is an ADF application which brings up an ADF form based on the parameters. Once the user enters the data, validations occur and the data is written into a total of 3 different Tables in the Database. Once the operation is finished, the user closes the popup by clicking on the "X" button of the popup window, which essentially does "popup.*hide()*".
    Limitations:
    <li>Since there are varied combination of parameter values and associated ADF forms, taskflows is not* an option.
    <li>Since the logic of generating the ADF form is not straightforward, ADF BC is not* an option.
    <li>Since validations are based on the value change listeners, the managed bean has to be a session scope_ bean.
    Problem:
    When, for the first time, the user clicks on the Edit button with a particular set of parameter values, the corresponding ADF form is displayed and things work normal. Since the managed bean is under session scope, the form generated for the first popup window stays the same for any subsequent popup windows, even when the URL and its parameters are completely different. As I can not listen to the popup close event, I cannot invalidate my session either.
    I tried using filters in the web.xml to grab the request and apply the business logic. Due to the presence of multiple value change listeners (too many <tt>autosubmit=true</tt>), every value change listener triggers a request and so the business logic gets applied with every value change.
    After some tests, I deduced that the difference between the call from iFrame and the call from value change is the HTTP Request Method - GET for iFrame and POST for value change listener. So in my filter I apply the business logic when there is a GET request and not apply when its a POST request.
    Turns out, that is not a valid enough differentiation between the two requests being made. Sometimes, even the value change listeners are issuing a GET request.
    Question:
    *<font color="red">1</font>*. Is there a way to force the value change listeners to always trigger a POST request?
    *<font color="red">2</font>*. Is there a way to differentiate the requests originating from the other team's Product and those generated by my own value change listeners?
    *<font color="red">3</font>*. Is there a different approach, incorporating the above-mentioned limitations, to clear out the session scope each time when a request is made through iFrame? That is, whenever a request is made through the other team's Product?
    Edited by: user737922 on Apr 13, 2011 10:58 AM

    _(Temporary) Solution_:
    Summary:
    I am using the request parameter <b><tt>_adf.ctrl-state</tt></b> to differentiate between the HTTP requests that my application receives.
    Details:
    When I receive the request from the other team's Product, I receive a <tt>GET</tt> and a <tt>adf.ctrl-state</tt> value which I store into a local variable in my session-scoped managed bean. The <tt>adf.ctrl-state</tt> value stays the same for all requests (<tt>GET</tt> or <tt>POST</tt>) made from within my own application. It changes only when there is a new request from the other team's Product.
    Also, as my application is accessed through an iFrame, there is no possibility of the generated URL being modified by the end-user.
    For now it seems that the solution is appropriate but I am not fully confident if relying on the <tt>_adf.ctrl-state</tt> value is the best approach.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Value change listener method on h:selectBooleanCheckbox in h:dataTable

    Hello,
    Does JSF handle value change listeners as expected when they are attached to h:selectBooleanCheckbox components within an h:dataTable?
    In the following example, I have a JSP that has some h:selectBooleanCheckbox components nested in an h:dataTable, and some that aren't. When I bulid and deploy the example to Tomcat 5.5, I can see (using the log4j output) that the value change listener methods for the checkboxes that are NOT in the dataTable are fired, but the ones that are in the dataTable do not get fired.
    I am using Sun's RI of JSF, version 1.1.0.1.
    Thanks,
    Scott
    ----------------------------- JSP:
    <%@ page language="java" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <f:view>
    <h:form>
    <h:dataTable value="#{checkboxBean.beans}" var="thisBean">
         <h:column>
              <h:outputText  value="#{thisBean.id}: " />
         </h:column>
         <h:column>
              <h:selectBooleanCheckbox value="#{thisBean.checked}" valueChangeListener="#{checkboxBean.somethingChanged}" />
         </h:column>
    </h:dataTable>
         <h:panelGrid columns="2">
              <h:outputText value="One:"/>
              <h:selectBooleanCheckbox id="firstOne" valueChangeListener="#{checkboxBean.somethingChanged}" />
              <h:outputText value="Two:"/>
              <h:selectBooleanCheckbox id="secondOne" valueChangeListener="#{checkboxBean.somethingChanged}" />
              <h:panelGroup/>
              <h:commandButton value="Do Stuff" action="#{checkboxBean.doStuff}" />
         </h:panelGrid>
    </h:form>
    </f:view>----------------------------- Beans:
    package workshop;
    import javax.faces.event.ValueChangeEvent;
    import org.apache.log4j.Logger;
    * Test attaching value change listener methods to checkboxes.
    public class CheckboxBean {
        private static final Logger logger = Logger.getLogger(CheckboxBean.class);
        private SomeBean[] beans = null;
        public CheckboxBean() {
            logger.debug("CheckboxBean()");
        public String load() {
            SomeBean[] someBeans = new SomeBean[3];
            someBeans[0] = new SomeBean("firstGuy", false);
            someBeans[1] = new SomeBean("2ndGuy", false);
            someBeans[2] = new SomeBean("third", false);
            this.setBeans(someBeans);
            return null;
        public String doStuff() {
            logger.debug("doStuff()");
            return this.load();
        public void somethingChanged(ValueChangeEvent e) {
            logger.debug("somethingChanged() in component with id " + e.getComponent().getId() );
        public SomeBean[] getBeans() {
            logger.debug("getBeans()");
            return this.beans;
        public void setBeans(SomeBean[] beans) {
            logger.debug("setBeans()");
            this.beans = beans;
    package workshop;
    public class SomeBean {
        private boolean checked = false;
        private String id = null;
        public SomeBean() {
        public SomeBean(String anId, boolean bool) {
            super();
            this.id = anId;
            this.checked = bool;
        public String getId() {
            return this.id;
        public void setId(String id) {
            this.id = id;
        public boolean isChecked() {
            return this.checked;
        public boolean getChecked() {
            return this.checked;
        public void setChecked(boolean checked) {
            this.checked = checked;
    }----------------------------- faces-config.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!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>
      <managed-bean>
        <description>Checkbox bean.</description>
        <managed-bean-name>checkboxBean</managed-bean-name>
        <managed-bean-class>workshop.CheckboxBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>
    </faces-config>----------------------------- log4j config:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
        <appender  name="RollingFile" class="org.apache.log4j.RollingFileAppender" >
              <param name="File" value="/Users/scott/workshop/logs/workshop.log"/>
            <param name="Append" value="false"/>
            <param name="MaxFileSize" value="4096KB" />
            <param name="MaxBackupIndex" value="4" />
            <layout class="org.apache.log4j.PatternLayout">
              <param name="ConversionPattern" value="%d{DATE} %-5p %-15c{1} : %m%n"/>
            </layout>
        </appender>
        <category name="workshop" >
          <priority value="debug" />
        </category>
        <root>
            <priority  value="warn" />
            <appender-ref  ref="RollingFile" />
        </root>
    </log4j:configuration>

    I have Just run into the same problem. When using the following code inside a data table the valueChangeListener event is not fired when the checkbox has it's value changed. Is this a bug?
    I created a simple page with just a form and the selectBooleanCheckbox. This time the valueChangeListener event fired OK. It seems the problem only occurs when the check box is inside the dataTable
    here is the code snippet
    <h:form >
    <h:column>
    <f:facet name="header">
         <h:outputText value="Add to Basket"/>
    </f:facet>
    <h:selectBooleanCheckbox immediate="true" valueChangeListener="#{reportsResultHandler.addToBasket}" value="#{reportsResultHandler.addbasketChecked}" onchange="this.form.submit
    ();"/>                              
    </h:column>
    </h:form>

  • Value-Changed Events

    There are two basic events, action and value-changed events.
    How is the server informed of a value-changed event? Does this include javaScript? If not, how is this handeled?
    Thx,
    Sven Haiges

    JSF is a server-side technology, so while JavaScript can be generated for some client-side behavior, the bulk of the processing (and the only processing that is guaranteed to work for all client types) happens on the server.
    Value-changed events are generated on the server when the form is submitted, by comparing the component's old value to the new value recieved with the request. In other words, these events are not triggerd by simply changing the value in the browser; the form must be subitted before the event is triggered (which, of course, can be initiated by JavaScript code immediately when the value is changed in some client-types).
    I hope this helps.

  • How to binding and change VM property value when DataTrigger?

    Hi all,
    Please see the below code. The current work is when mouse over myButton then set textbox value as 3. Then binding this value to ViewModel property, at this time, the new value of ViewModel property also be 3.
    The textbox just like a bridge. Can I remove this bridge and change the VM property directly when <setter..... in myTrigger style? thanks.
    <Style x:Key="myTrigger" TargetType="TextBox">
    <Style.Triggers>
    <DataTrigger Binding="{Binding IsMouseOver, ElementName=myButton}" Value="True">
    <Setter Property="Text" Value="3"></Setter>
    </DataTrigger>
    </Style.Triggers>
    </Style>

    This definitely works:
    <Button Height="50" Width="100">
    <Button.Triggers>
    <EventTrigger RoutedEvent="Button.MouseEnter">
    <BeginStoryboard>
    <Storyboard
    Storyboard.Target="{Binding}"
    Storyboard.TargetProperty="MyNum">
    <DoubleAnimation To="3.0" />
    </Storyboard>
    </BeginStoryboard>
    </EventTrigger>
    </Button.Triggers>
    </Button>
    Viewmodel:
    public class MainWindowViewModel : DependencyObject
    public double MyNum
    get { return (double)GetValue(MyNumProperty); }
    set
    SetValue(MyNumProperty, value);
    // Using a DependencyProperty as the backing store for MyNum. This enables animation, styling, binding, etc...
    public static readonly DependencyProperty MyNumProperty =
    DependencyProperty.Register("MyNum", typeof(double), typeof(MainWindowViewModel), new PropertyMetadata(callBack));
    static void callBack(DependencyObject d, DependencyPropertyChangedEventArgs e)
    Console.WriteLine(e.NewValue.ToString());
    Hope that helps.
    Recent Technet articles:
    Property List Editing ;  
    Dynamic XAML

  • ADFPhaseListener prepareRender and component binding problem

    I´m Using ADF Faces and using the ADFPhaseListener. My BackingBean extends from the PageController class
    and so can use prepareModel(LifecycleContext context) or prepareRender(LifecycleContext context). This works fine so far. The
    event handler methods are called as expected (in my example prepareRender). But I have one question.
    I´m using Component binding in my JSF-Page:
    <af:inputText binding="#{backing_untitled1.inputText1}" id="inputText1">
    Code snippet from my ControllerClass
    public class Untitled1 extends PageController{
    CoreInputText inputText1;
    public void setInputText1(CoreInputText inputText1) {   
    System.out.println("setInputText1");
    this.inputText1 = inputText1;
    public void prepareRender(LifecycleContext context) {
    super.prepareRender(context);
    System.out.println("inside prepareRender");
    I´ve written a second PhaseListener that just print´s out the JSF lifecycle phase numbers for better tracing.
    The first time I call my JSF-Page the following output is generated:
    07/01/03 08:32:38 Before Phase: 1 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:32:38 After Phase: 1
    07/01/03 08:32:38 inside prepareRender
    07/01/03 08:32:38 Before Phase: 6 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:32:39 setInputText1
    07/01/03 08:32:40 After Phase: 6
    I can see that the prepareRender is called before phase 6. The component binding is done in phase 6. What I would like to
    do is access the component binding in my prepareRender method. But this is not possible as it is null before phase 6.
    Is there a way to create event handling code after the component binding has taken place?
    When I do a postback (second call to the same JSF page) this thing changes
    07/01/03 08:37:23 Before Phase: 1 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 setInputText1
    07/01/03 08:37:24 After Phase: 1
    07/01/03 08:37:24 Before Phase: 2 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 After Phase: 2
    07/01/03 08:37:24 Before Phase: 3 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 After Phase: 3
    07/01/03 08:37:24 Before Phase: 4 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 After Phase: 4
    07/01/03 08:37:24 Before Phase: 5 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 After Phase: 5
    07/01/03 08:37:24 inside prepareRender
    07/01/03 08:37:24 Before Phase: 6 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 After Phase: 6
    Here in my prepareRender method I could access the component binding as it has been initialized in phase 1.
    Thanks in advance
    Rainer

    hi, you can use this way to initially a value:
    public void setInputText1(CoreInputText inputText1) {
    this.inputText1 = inputText1;
    if( !AdfFacesContext.getCurrentInstance().isPostback() ){
    this.inputText1.setValue("somevalue");
    in the RenderModel phase is not possible set value to a component because this one is null, as you have said.. by this way you can do this too:
    public void setInputText1(CoreInputText inputText1) {
    this.inputText1 = inputText1;
    if( !AdfFacesContext.getCurrentInstance().isPostback() ){
    DCIteratorBinding ib = (DCIteratorBinding)Utilidades.resolveExpression("#{bindings.BanksView1Iterator}");
    RowIterator iter = ib.getRowSetIterator();
    Row row = iter.first();
    if (row != null){
    this.inputText1.setValue(row.getAttribute(BanksViewRowImpl.COD));}
    }

  • Setting bind variable value programmatically for master and child VO's

    Defined following BC:
    Serv VO - Master VO, has Bind_cNum (bind variable)
    ServDetail VO - Child VO, has Bind_cNum2 (bind variable)
    ServViewLink VL - View link between Serv VO & ServDetail VO
    in AMModule Impl have custom WS:
    public List<ViewRowImpl> getMyServices(String cNum)
    List<ViewRowImpl> result = new ArrayList<ViewRowImpl>();
    ViewObjectImpl vo1 = getServ(); //Master VO
    vo1.setNamedWhereClauseParam("Bind_cNum", cNum);
    vo1.setForwardOnly(true);
    ViewObjectImpl vo2 = getServDetail(); //Child VO
    vo2.setNamedWhereClauseParam("Bind_cNum2", cNum);
    vo1.executeQuery();
    while (vo1.hasNext()) {
    result.add((ViewRowImpl)vo1.next());
    return result;
    I am passing same cNum parameter to both Serv VO (Master VO) and ServDetail VO (child VO) as above. (this is in addition to view link bind variable :Id)
    It shows in the logs that it is setting the values correctly:
    <ViewRowSetImpl> <setNamedWhereClauseParam> [382] Serv ViewRowSetImpl.setNamedWhereClauseParam(Bind_cNum, 11771370)
    <ViewRowSetImpl> <setNamedWhereClauseParam> [383] ServDetail ViewRowSetImpl.setNamedWhereClauseParam(Bind_cNum2, 11771370)
    <ViewRowSetImpl> <doSetWhereClauseParam> [383] Serv ViewRowSetImpl.doSetWhereClause(-1, Bind_cNum, 11771370)
    <ViewRowSetImpl> <execute> [385] Serv ViewRowSetImpl.execute caused params to be "un"changed
    <OracleSQLBuilderImpl> <bindParamValue> [394] Binding param "Bind_cNum": 11771370
    <ADFLogger> <addContextData> Execute query
    -- when executing view link
    <ViewRowSetImpl> <setParamValues> [425] ServViewLink_0 ViewRowSetImpl.setParamValues params changed
    <ViewRowSetImpl> <doSetWhereClauseParam> [426] ServViewLink_0 ViewRowSetImpl.doSetWhereClause(-1, Bind_cNum2, null)
    <ViewObjectImpl> <bindParametersForCollection> [436] For RowSet : ServViewLink_0
    <OracleSQLBuilderImpl> <bindParamValue> [437] Binding null of type 12 for "Bind_cNum2"
    <OracleSQLBuilderImpl> <bindParamValue> [438] Binding param "Bind_Id": 5018
    from above log, when ServViewLink_0 is executed, it is changing Bind_cNum2 bind variable to null.
    how can i pass same bind variable value to both Master and Child view objects from AM Impl.java
    Edited by: bsrao on Oct 11, 2012 6:07 PM
    Edited by: bsrao on Oct 11, 2012 6:10 PM
    Edited by: bsrao on Oct 11, 2012 6:12 PM

    Try executing the vo1 query before setting the bind variable for vo2, then execute the vo2 query (if that's what you want to do).

  • Urgent help ----problem of component id and attribute value

    I want to produce a dynamic menu that compoment id and attribute value will be dynamic assigned when logon to system. That means i have to use id="#{aid}" and value="#{avalue}" in following codes.
    The problem are:
    1. Component id looks only accepts constant (hard code data) insteads of varable. I changed id="ADMIN", and it works. It can be empty, and tag will give me one. Therefore, it is not too much affected me.
    2. The f:attribute value, when value="Value" works. However, when value="#{avalue}", first time works, second time it throws Illegal State Exception. I really need this value be assigned by varable.
    Can anyone help me out?
    ----------------------------------------------Code----------------------------------------------
    <h:command_link id="#{aid}" action="#{Action.action}" >
              <f:action_listener type="my.MenuListener"/>
              <h:output_text value="Logon"/>
              <f:attribute name="COMMAND" value="#{avalue}"/>
    </h:command_link>

    -----------2 TreeMenu---------------
    public class MenuTree implements Serializable{
    private String treeId = null;
    private String name = null;
    private Map submenus = new TreeMap(); // name as key, submenu is value;
    private String actionClass = null;
    private boolean isLeaf = false;
    private boolean isRoot = true;
    private MenuTree parent = null;
    public boolean isRoot() {
         return isRoot;
    public void setRoot(boolean root) {
         isRoot = root;
    public MenuTree(){
    public MenuTree getParent(){
         return parent;
    public void setParent(MenuTree parent){
         this.parent = parent;
         if(parent != null) parent.putSubmenu(treeId, this);
         isRoot = false;
    public String getName() {
         return name;
    public void setName(String name) {
         this.name = name;
    public Map getSubmenus() {
         return submenus;
    public boolean getIsNode(){
         return submenus.size() > 0;
    public void putSubmenu(String name, MenuTree menu){
         submenus.put(name, menu);
         * @return Returns the isLeaf.
         public boolean getIsLeaf() {
              return isLeaf;
         public boolean getIsRoot() {
              return isRoot;
         * @param isLeaf The isLeaf to set.
         public void setLeaf(boolean isLeaf) {
              this.isLeaf = isLeaf;
         * @param submenus The submenus to set.
         public void setSubmenus(Map submenus) {
              this.submenus = submenus;
         * @return Returns the actionClass.
         public String getActionClass() {
              return actionClass;
    public void setActionClass(String actionClass) {
         this.actionClass = actionClass;
         public String getTreeId() {
              return treeId;
         * @param id The id to set.
         public void setTreeId(String treeId) {
              this.treeId = treeId;
    ------------3 JSP if want to test change subview to view. I am sure the treeId have value---------------------
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <% request.setAttribute("CONTEXT_PATH", request.getContextPath()); %>
    <LINK rel="stylesheet" type="text/css" href='<c:out value="${requestScope.CONTEXT_PATH}"/>/style/menutree.css'/>
    <SCRIPT type='text/javascript' src='<c:out value="${requestScope.CONTEXT_PATH}"/>/js/hideshow.js'></SCRIPT>
    <!--f:loadBundle basename="bundle.common.Menu" var="bundle"/-->
    <f:subview id="userMenuView">
    <h:form id="userMenuForm">
    <c:set var="root" value="${sessionScope.menuTree}"/>
    <table class="" width="150px" bgcolor="blue">
    <c:forEach var="menuBar" begin="0" items="${root.submenus}">
    <c:set var="menu" value="${menuBar.value}"/>
         <tr>
         <td>
         <c:choose>
              <c:when test="${menu.isLeaf}">
                   <c:set var="menuJSF" value="${menu}" scope="request"/>
                   <h:command_link action="#{Action.action}">
                        <f:action_listener type="com.nusino.web.listener.menu.MenuListener"/>
                        <h:output_text value="#{menuJSF.name}"/>
                        <f:attribute value="#{menuItemJSF.treeId}">
                   </h:command_link>
              </c:when>
              <c:otherwise>
                   <span class="" onclick="javascript:hideshow('<c:out value="${menu.treeId}"/>')">
                        <c:out value="${menu.name}"/>
                   </span>
                   <div id='<c:out value="${menu.treeId}"/>' >
                   <table class="">
                   <c:forEach var="submenu" begin="0" items="${menu.submenus}">
                        <c:set var="menuItem" value="${submenu.value}"/>
                        <tr>
                        <td>
                        <c:choose>
                             <c:when test="${menuItem.isLeaf}">
                                  <c:set var="menuItemJSF" value="${menuItem}" scope="request"/>
                                  <h:command_link action="#{Action.action}">
                                       <f:action_listener type="com.nusino.web.listener.menu.MenuListener"/>
                                       <h:output_text value="#{menuItemJSF.name}"/>
                                       <f:attribute value="#{menuItemJSF.treeId}">
                                  </h:command_link>
                             </c:when>
                             <c:otherwise>
                                  <span class="" onclick="javascript:hideshow('<c:out value="${menuItem.treeId}"/>')">
                                  <c:out value="${menuItem.name}"/>
                                  </span>
                                  <div id='<c:out value="${menuItem.treeId}"/>' >
                                       <table class="">
                                            <c:forEach var="item" begin="0" items="${menuItem.submenus}">
                                                 <c:set var="itemObj" value="${item.value}"/>
                                                 <tr>
                                                 <td>
                                                 <c:choose>
                                                      <c:when test="${itemObj.isLeaf}">
                                                      <c:set var="itemObjJSF" value="${itemObj}" scope="request"/>
                                                           <h:command_link action="#{Action.action}">
                                                                <f:action_listener type="com.nusino.web.listener.menu.MenuListener"/>
                                                                <h:output_text value="#{itemObjJSF.name}"/>
                                                                <f:attribute value="#{itemObjJSF.treeId}">
                                                           </h:command_link>
                                                      </c:when>
                                                      <c:otherwise>
                                                           <span class="">
                                                           <c:out value="${itemObj.name}"/>
                                                           </span>
                                                      </c:otherwise>
                                                 </c:choose>
                                                 </td>
                                                 </tr>
                                            </c:forEach>
                                       </table>
                                  </div>
                             </c:otherwise>
                        </c:choose>
                        </td>
                        </tr>
                   </c:forEach>
                   </table>
                   </div>
              </c:otherwise>
         </c:choose>
         </td>
         </tr>
    </c:forEach>
    </table>
    <script language= "javascript" >
         function prehide(){
              <c:forEach var="menuBar" begin="0" items="${root.submenus}">
                   <c:set var="menu" value="${menuBar.value}"/>
                   <c:if test="${!menu.isLeaf}">
                        hide('<c:out value="${menu.treeId}"/>');
                        <c:forEach var="submenu" begin="0" items="${menu.submenus}">
                             <c:set var="menuItem" value="${submenu.value}"/>
                             <c:if test="${!menuItem.isLeaf}">
                                  hide('<c:out value="${menuItem.treeId}"/>');
                             </c:if>
                        </c:forEach>
                   </c:if>
              </c:forEach>
         if(document.all){
              prehide();
    </script>
    </h:form>
    </f:subview>

  • Error when I put a component in the stage and I change any property

    Hello
    I'm using Flash CS4, as3 and adobe air file. I have an application with 3 scenes, first scene to login, second to set up, and third to see an video.
    The problem is that, when I put a component in the second or third scene, if a change any property in the component inspector, any property it gives me error. So put the component and I change property by code in as3.
    But I'm doing things with FLVPlayback component, and now before enter the scene gives me error, the solution will be to get the original properties, but I don't remember, I could install other time Flash CS4, but I can do that for any componet, better know the solution.
    For example, I have an as file who is the class named p.e. MyMainclass, and in the scene3, I put FLVPlayback, who default values it's the last I used (I don't remember default after instalation), if any code in as3, it gives me this error:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at com.program::MyMainClass/__setProp___id2__scene3_myvideo1_1()[com.program.MyMainClass::__ setProp___id2__scene3_myvideo1_1:7]
    I remove this component, I put another one I never used, it doesn't give me error, I change any property in the object inspector, p.e. color, it gives me error, I change to original property again, and then NO ERROR.
    Thanks in advance

    I would reccomend that you not use scenes for that purpose, not exactly sure why  but scenes are unreliable. Try putting all of your content in one scene, one timeline and just add a few stop() 's at the end of each "scene", then in your code remove scene2 and scene3 three references, and you'll possibly need to change frame anchors/targets also if you have them.
    The error indctates that you have called an object that does not exist at the time the code is run, check where you placed your code, should be frame one, scene1, and also check if you have objects entering the stage down the timeline, that do not enter in frame 1, possibly the movieClip? if so add another keyframe on your actions layer on the same frame as the object and enter the call function for it there.

Maybe you are looking for