How to trigger a value change listener in JSF without submitting the form

hi friends,
I have a JSF Page which contains a check box and a text box.
I made the text box property as readonly.
when i click the check box , i want to make my text box as editable.
i achieved the above task by submitting the whole form when i click the check box.
i want to acheive the same functionality with out submitting the form.
In one of the references it is stated that "Value-changed handlers are executed if the page is submitted and the value of the component has changed."
hope you got the question.
please let me know, if you know the answer.

Hi,
If at all you dont want to submit the form and wanna reflect same form's field(s) as per the change in drop-down/check-box,
you can simply achive it using traditional way of 'JavaScript'.
For that you may typically give <h:form> tag any specific id say
<h:form id="myForm"> and for dropdown/checkbox also you may give id say
<h:selectBooleanCheckbox id="group" onchange="javascript:reflectChangedValue();"  ... >
</h:selectBooleanCheckbox>and in the same JSP you can write any JS function say reflectChangedValue() as
function reflectChangedValue()  {
     var formPrefix  = "myForm:";
     var groupId = formPrefix + "group";
     var value = document.getElementById(groupId).value;
      if(value) {
           // enale textbox here
      } else {
           // disable textbox here
}For formPrefix and groupId, f you are having any doubts, you can refer to 'view source' from the browser,
generated HTML of the working JSP.

Similar Messages

  • Populating values in jsp without submitting the form

    Hi,
    I have a jsp page in which i have 2 select boxes. The values to these select boxes should come from database. When i change the selection of select box, the corresponding values from database should be displayed in the other select box without submitting the form.
    How to accomplish that.
    Any one having any idea about how to implement this stuff, please reply.
    Thanks in advance,
    Joby.

    You should devide the JSP into two frames and make one frame size to 0 so it should not be visible to the use ,and put one jsp in this frame ,tht will work as the hidden jsp.
    now in other frame put ur main jsp and on the change event of th select call a java script function and in this function pass the parametr to the hidden jsp like
    parent.frames["hiddenframename"].document.location="hiddenJspName.jsp?parameter1=value1
    and now in hodden jsp populate the data frm database based on passed parameter and after getting the data fillup the select on the second frame.
    try it and if not work thn write me...
    Bye.

  • How to Save State on an Entry Form prior to Submitting the Form?

    I want to be able to save the values the user enters to fields on the entry form if they navigate away from the page and come back (without the user clicking the submit button for the form.) For example, one of the input fields has a goLink to go to another page to lookup a field value - when the user returns from the page, all other form field values are cleared. If the user does submit the form by clicking the command button, then all form field values are saved (if the user navigates from the page and comes back, all values are retained.) What I'm trying to do then is somehow save the values (passivate the state) for the field the user has filled in when the user navigates from the page without submitting the form. Any suggestions?
    I am using a read-only View Object with all transient values. The VO is configured to passivate state including all transient values. The initial row is created programmatically; there will only be one row for the VO used as an entry form. I am not using a backing bean for the values and would prefer not to use one, but would rather use the VO's capability to passivate state to save the data values. The question then seems to be how to force the VO to passivate state prior to the form being submitted.
    thanks
    Message was edited by:
    javaX

    "My hunch is that the real problem is that the fields are not being set into the bindings due to the use of immediate="true"."
    Yes. Now I see that is the real problem. Is there anyway to force setting the bindings from the input form field values if the user navigates from the page using a goLink, or commandButton with immediate="true" other than overriding the default FacesPageLifecycle classes?
    I'd prefer not to have to do that unless necessary, and, if I over-ride that method, then how could I get it to work normally when the user presses the commandButton at the end of the form and I do want all validation checks to be performed (immediate=false for the form's submit button; immediate=true only for lookup commandButtons used for certain fields)?
    Here's an overview of how I set the page up:
    1. create transient view object; all attributes marked as always updateable; passivate state=true for VO and all transient values; no key id field selected (will only ever be one row - just using VO to save values that will eventually be used to do an insert to the database);
    2. transient VO added to Application Module
    3. Add data control to .jspx page as an ADF Form (not an ADF Creation Form)
    4. Add code to AM to create the initial row for the input form
    protected void prepareSession(Session session) {
    super.prepareSession(session);
    insertTransientViewObjRows();
    private void insertTransientViewObjRows() {
    ViewObject transientvo = getViewObj1();
    transientvo.clearCache();
    transientvo.insertRow(transientvo.createRow());
    --- Entry Form .jspx pagedef.xml snippet ---
    <executables>
    <iterator id="MyIterator" RangeSize="10" Binds="MyView"
    DataControl="AMDataControl"/>
    </executables>
    <bindings>
    <attributeValues id="sponsorid" IterBinding="MyIterator">
    <AttrNames>
    <Item Value="sponsorid"/>
    </AttrNames>
    </attributeValues>
    --- Entry Form .jspx page snippet ---
    <h:form>
    <af:panelForm>
    <af:panelLabelAndMessage label="#{bindings.sponsorid.label}">
    <af:panelGroup layout="horizontal">
    <af:inputText value="#{bindings.sponsorid.inputValue}"/>
    // state will not be saved for other form field values if use immediate="true" when temporarily navigate away from page and return; don't want to validate other form fields here
    <af:commandButton text="Lookup Details"
    action="lookup-page" immediate="true"/>
    </af:panelGroup>
    </af:panelLabelAndMessage>....
    // state will be saved with immediate="false" when user submit forms at end of entry (need to perform validation of form's required fields here)
    <af:commandButton text="Continue to Next Step" immediate="false"
    action="nextpage"/>
    Message was edited by:
    javaX

  • Value change listener method does not refresh value

    Hi Frank,
    According to your documentation ADF Faces: How-to build dependent lists boxes with ADF and ADF Faces I have created dependent list box and it is working properly.
    Now in the similar way I have created a form where one attribute is set as select one choice and it takes value from a lov and this attribute have a value change listener event and when selecting a value for this attribute from lov, in backing bean it will set another attribute of the form and the value will be taken from the other field of the lov for the current row.
    But when I am running this, 1st time when I am selecting a value from lov, the 2nd attribute of the form gets its value but next time when I am selecting another value in LOV, the value in the other attribute is not changing accordingly.
    My original form is (test_date,machine_code,machine_no...)
    I have created LOV for machine_code.
    This LOV is --select machine_code,machine_no from machine_mast;
    This LOV returns machine_code to the machine_code field of my main form.
    For machine_code, I have created a value change listener method and set its autosubmit property to true and for machine_no field I have set its partial trigger property to the ID of machine_code field.
    The value change listener code is
    BindingContainer bindings = this.getBindings();
    DCIteratorBinding itr = (DCIteratorBinding)bindings.get("lov2_sqc0400_1Iterator");
    Row rw = itr.getRowAtRangeIndex(((Integer)valueChangeEvent.getNewValue()).intValue());
    Object machine_no= rw.getAttribute("MchnNo");
    inputText2.setValue(machine_no);
    Please help
    Regards/Thanks
    SK

    Hi All,
    Can anyone please help me?
    Thanks/Regards
    SK

  • Copy the values input in input text 1 to input text 2 using value change listener

    Hello ,
    I have two input texts :
    input text 1 & input text 2 .
    I need to copy the values input in input text 1 to input text 2 .
    How do I implement this using value change listener ?
    I did the following steps :
    1) I selected input text 1 and chose Value Change listener --> edit .
       Typed a new bean & class name .
       Which method name should I add ?
    Any help please ?

    Hi,
    Give any name to the method and bind the two input text to manged bean using bindings attribute of InputText. just follow the below given code
    Ex:
    test.java class
        private RichInputText inputVal1;
        private RichInputText inputVal2;
        public Test() {
        public void ValChange(ValueChangeEvent valueChangeEvent) {
            // Add event code here...
            inputVal2.setValue(inputVal1.getValue().toString());
        public void setInputVal1(RichInputText inputVal1) {
            this.inputVal1 = inputVal1;
        public RichInputText getInputVal1() {
            return inputVal1;
        public void setInputVal2(RichInputText inputVal2) {
            this.inputVal2 = inputVal2;
        public RichInputText getInputVal2() {
            return inputVal2;
    test.jspx page
    <af:inputText label="Label 1" id="it1" valueChangeListener="#{backingBeanScope.TestBean.ValChange}"
                                  binding="#{backingBeanScope.TestBean.inputVal1}" autoSubmit="true"/>
                    <af:inputText label="Label 2" id="it2" binding="#{backingBeanScope.TestBean.inputVal2}"
                                  partialTriggers="it1"/>
    Thanks
    nitesh

  • ADF :  Value change listener for the whole jsff page

    Is there any feature to have a value change listener for the whole jsff page ?
    How to know if user has change something in the page i.e. how to know whether the page is dirty ?

    User please tell us your jdev version!
    Read this blog https://blogs.oracle.com/groundside/entry/ever_wondered_how_uncommitteddatawarning_works
    Timo

  • 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>

  • Get action or value change listener to be invoked from phaseEvent

    Hi,
    Does a PhaseEvent object has information for which action or value change listener is to be invoked?
    I have implemented a common logging method which has to be called on any action or value change event.
    The method requires the name of the method bound to action or value change listener.
    It is convinient if a phaseEvent object has information for the listener's method name because in that case I don't have to write a code calling the logging method in each action or value change listener but only in PhaseListener.
    Regards,
    Kenji

    Same as my thread...no answers...!

  • Problem in getting the current value of the drop down while calling value change listener

    I have 2 drop down list. I am trying to get the value of first drop down from other drop downs value change listener. Initially one drop down contains a default value. First time I got the value while calling the value change listener. But if I change the default value to other in the first drop down and call the value change listener of the second drop down then I got the old value in the bean. Can anyone suggest a process

    If I use the following code it gives me the current index.
                valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());
                System.out.println(valueChangeEvent.getNewValue());
    This is also giving me current index.
    BindingContainer container = BindingContext.getCurrent().getCurrentBindingsEntry();
    AttributeBinding attrIdBinding = (AttributeBinding)container.getControlBinding("PersonTypeId1");
    if(attrIdBinding.getInputValue()!=null)
                   System.out.println(attrIdBinding.getInputValue().toString());
    But at last I got some help from Shay Shmeltzer's Weblog.
    BindingContainer bindings =
                    BindingContext.getCurrent().getCurrentBindingsEntry();
                    // Get the sepecific list binding
                    JUCtrlListBinding listBinding =
                    (JUCtrlListBinding)bindings.get("PersonTypeId1");
                    // Get the value which is currently selected
                    Object selectedValue = listBinding.getSelectedValue();
                      long value =0L;
                    if(selectedValue!=null){
                        System.out.println("Sudip.. Person Type using bindings"+selectedValue.toString());
    But this returns "ViewRow [oracle.jbo.Key[300000860721156 ]]"
    300000860721156 is the original value.. Would you please help me to figure it.

  • Getting a value of another textbox in value change listener

    Hi
    I am associating a value change listener with textbox1. and i need the values of textbox2 inside the listener. So every time, value of textbox1 changes , i want to call a listener which executes a query depending on the value of textbox2 which is constant. But i am not able to get the value of textbox2 inside the listener method.
    Thanks in advance..

    Read on about the JSF lifecycle. The valuechangelistener will be fired at the end of the 3rd phase of the JSF lifecycle (process validations) and the input values will be set in the bean in the 4th phase of the JSF lifecycle (update model values).
    In your case, a complete rewrite of the code may be more useful. If you are actually not interested in the difference between the old value and the new value, then remove the valuechangelistener and put the code logic in the action method of the bean. This will be executed in the 5th phase of the JSF lifecycle (invoke application), after the input values are been set.
    Or, in my opinion better, introduce some AJAX framework and make use of its capabilities. For example Ajax4jsf. It saves you from synchronous form submits on every entered character which may lead to poor user experience.
    This practical article might be helpful in understanding the JSF lifecycle: [http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html]

  • How to search this value in oracle database to find out the table

    Hi expert,
    I know there is a value in oracle database, please show me how to search this value in oracle database to find out the table holding this value.
    Many Thanks,

    918440 wrote:
    Hi friends,
    this question is really practical, I already know there is value from application saved in database, I want to search the whole database to figure out which table the value is contained.write SQL that writes SQL to query every table.
    Handle:     918440
    Status Level:     Newbie
    Registered:     Mar 2, 2012
    Total Posts:     20
    Total Questions:     10 (10 unresolved)
    why do you waste time here when you NEVER get any answer to any question you post?

  • Getting the value of iframe to next page while submitting the form

    hi,
    I have used iframe to change the text as bold or italic . This is changing the text as bold or italic.
    iframe has properties name & id, by using i have tried to get the value while submitting the form , I couldn't get the value.
    can u please help me how to read the iframe content.
    the html code is
    *<div><iframe id="xxx" name="xxxx"></frame></div>*

    Hi Anjan,
    I am using this workflow for an employee to send leave request. I have created an event in a program using SAP_WAPI_CREATE_EVENT to create an event zabsence_form. This event is used to trigger the workflow. I have created a table for leave details. The container used in the form is of that table type.
    The agent for ZFILL_ABS_FORM (for filling leave application)  is the workflow initiator and ZABS_APPROVE is a user who is his manager.
    Now the scenario is that I need to do some screen changes for those two users. For that, I need to get the workflow initiator value in the PBO of the form screen. Any way to do that?

  • Is there a way that you can have two different text fields (email, phone) that one at least one of them must be completed before submitting the form? Can it be done using javascript in the validation tab? if so, how?

    Is there a way that you can have two different text fields (email, phone) that one at least one of them must be completed before submitting the form? Can it be done using javascript in the validation tab? if so, how?

    Here is one solution:
    // mouse up action for submit button;
    function GetField(cName) {
    // get field object for cName field with error checking;
    var oField = this.getField(cName);
    if(oField == null) app.alert("Error accessing field named " + cName + "\nPleae verigy field name, spelling and capitalizeation.", 1, 0);
    return oField;
    } // end GetField function;
    var oPhone = GetField("phone");
    oPhone.required = oPhone.value == oPhone.defaultValue;
    var oEmail = GetField("email");
    oEmail.required = oEmail.value == oEmail.defaultValue;
    if(oPhone.required && oEmail.required) {
    app.alert("Missing required fields.", 1, 0);
    } else {
    app.alert("Submitting form", 3, 0);
    // additional code for submission;

  • How can I sync my iPod with my computer without deleting the songs that are on my ipod

    how can I sync my iPod with my computer without deleting the songs that are on my ipod

    See this post by forum regular Zevoneer on transferring files from the iPod to your computer.
    tt2

Maybe you are looking for