Jsf command button action bean method call from text fox

Hai Friends,
I want call the command button action bean method from textbox entry time.
because i develop login form that time user enter user name and password if he press enter from password component that time i want to use the commandbutton action

What's the problem exactly? Won't the commandbutton action be invoked when you press [enter] in the textbox?

Similar Messages

  • Command Button action is bean method.How to pass parameter or reference ID?

    JDEV11gR1PS1/ADF
    A command button action's is bean method, as follows:
    <af:commandMenuItem id="gbl_cmi_1" action="#{tbBean.action1}"/> Bean code is something like
    public String action1() throws IOException {
    if (id.equals.("gbl_cmi_1"))...
    }Therefore, I'd like to be able to find out what the commandButton's ID is, for use in evaluation, etc.
    The reason being is that multiple commandButtons are actually being built dynamically as well, and the action may be a URL redirect. Therefore, I'm using the id to lookup what URL to redirect to.
    Ideas?
    Thanks.

    Hi,
    I think you can use f:attribute inside your commandButton.
    We use f:attribute inside button or link which hold a name/ value and we can read the value from backing bean as :
    public void addItemToCart(ActionEvent evt) {// this the actionListener of button or link
    Map attributes = evt.getComponent().getAttributes();
    String productId = attributes.get("attributeName");
    } Sameh Nassar

  • Action Listener Method called multiple times

    I have a page (fragment .jsff), containing a simple input text and a button called "search". When I click on "Search" the action listener is triggered multiple times. (The results are displayed in a table inside a panel collection).
    The results are actually coming back ok.
    When I debug the code, I can see the action listener method called twice.
    Do you know why is that?
    What should I be taking care of?
    This is my code :
    *** Fragment ****
    <af:commandButton text="#{identityBundle.search_label}" id="cb1"
    actionListener="#{UserDetailsBean.searchUsersListener}"
    disabled="#{!bindings.searchUsers.enabled}"/>
    *** Managed bean ***
    public void searchUsersListener(ActionEvent actionEvent) {
    // Add event code here...
    DCBindingContainer bindings = (DCBindingContainer)getBindings();
    DCIteratorBinding iter = bindings.findIteratorBinding("userIterator");
    DCDataRow row = (DCDataRow)iter.getCurrentRow();
    User user = (User)row.getDataProvider();
    boolean isSearchCriteriaPresent = false;
    if(user != null){
    String fn = user.getFirstname();
    if(fn != null && !fn.trim().equals("")){
    isSearchCriteriaPresent = true;
    user.setLastname(fn);
    user.setNonMTUserLogin(fn);
    try {
    Map <Object, Object> userMap = PropertyUtils.describe(user);
    for(Map.Entry<Object, Object> entry: userMap.entrySet()){
    if(entry.getKey() != null && entry.getValue() != null && !entry.getKey().toString().equalsIgnoreCase("class")){
    isSearchCriteriaPresent = true;
    break;
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    } catch (InvocationTargetException e) {
    e.printStackTrace();
    } catch (NoSuchMethodException e) {
    e.printStackTrace();
    if(!isSearchCriteriaPresent){
    user.setFirstname("*");
    OperationBinding opBinding = (OperationBinding)bindings.getOperationBinding("searchUsers");
    opBinding.getParamsMap().put("user", user);
    opBinding.execute();
    AdfFacesContext adfFacesCtx = AdfFacesContext.getCurrentInstance();
    Map<String, Object> scopePageFlowScopeVar= adfFacesCtx.getPageFlowScope();
    scopePageFlowScopeVar.put("userSearchCriteria", user);
    ADFContext adfCtx = ADFContext.getCurrent();
    Map sessionScope = adfCtx.getSessionScope();
    sessionScope.put("userSearchCriteria", user);
    setUserSearchCriteria(user);
    if(selectedUserID != null){
    selectedUserID.setValue(null);
    RichTable table = getUserResultsTable();
    DCIteratorBinding searchUsersIterator = (DCIteratorBinding)bindings.get("searchUsersIterator");
    Row[] rows = searchUsersIterator.getAllRowsInRange();
    if(rows.length > 0){
    RowKeySetImpl rks = new RowKeySetImpl();
    ArrayList keyList = new ArrayList();
    keyList.add(rows[0].getKey());
    rks.add(keyList);
    table.setSelectedRowKeys(rks);
    table.setDisplayRowKey(keyList);
    refreshState(table);
    if(!isSearchCriteriaPresent){
    user.setFirstname(null);
    else{
    deleteUserButton.setDisabled(true);
    resetPasswordButton.setDisabled(true);
    enableUserButton.setDisabled(true);
    disableUserButton.setDisabled(true);
    Thanks in advance for your help

    Hi,
    Can you try this?
    1. set partialSubmit=true for the "search" button
    2. set "search" button id as partialTrigger in your result table
    -Prasad

  • Button action event not call in dataprovider

    hi,
    i have JSF table and it's bound to Mysql database table. when i bound the table and run it's working properly but it's button action event is not call action. when i use static jsf table then it's table action event work properly.
    my jsp code is
    <ui:table binding="#{search.search_table}" id="search_table" lite="true" selectMultipleButton="true" sortPanelToggleButton="true"
                                style="height: 70px; left: 240px; top: 240px; position: absolute; width: 600px" title="Search Text :" visible="true" width="600">
                                <ui:tableRowGroup binding="#{search.tableRowGroup1}" id="tableRowGroup1" rows="5" sourceData="#{search.srch_tablevalDataProvider1}" sourceVar="currentRow">
                                    <!--    <ui:tableColumn headerText="Script" id="tableColumn2" width="700">
                                        <ui:staticText id="staticText4" text="#{currentRow.value['search_script']}"/>
                                    </ui:tableColumn>-->
                                    <ui:tableColumn binding="#{search.tableColumn13}" headerText="Search Word" id="tableColumn13" style="#{search.columnStyle}">
                                        <ui:staticText binding="#{search.search_word1}" id="search_word1" text="#{search.search_word1}"/>
                                    </ui:tableColumn>
                                    <ui:tableColumn binding="#{search.tableColumn4}" headerText="#{search_lang['search.contentName']}" height="39" id="tableColumn4"
                                        style="#{search.columnStyle}" width="100">
                                        <ui:staticText id="staticText1" onMouseOver="play_video(this);" text="#{currentRow.value['name']}"/>
                                    </ui:tableColumn>
                                    <ui:tableColumn binding="#{search.tableColumn6}" headerText="#{search_lang['search.srchTag']}" id="tableColumn6"
                                        sort="search_tags" style="#{search.columnStyle}">
                                        <ui:staticText id="staticText3" text="#{currentRow.value['search_tags']}"/>
                                    </ui:tableColumn>
                                    <ui:tableColumn binding="#{search.tableColumn5}" headerText="#{search_lang['search.tpDetail']}" id="tableColumn5" style="#{search.columnStyle}">
                                        <ui:imageHyperlink action="#{search.action}" id="imageHyperlink1" text="#{currentRow.value['details']}"/>
                                        <ui:button action="#{search.button2_action}" id="button2" text="Button"/>
                                    </ui:tableColumn>
                                </ui:tableRowGroup>
                             </ui:table>and back bean code is
    public String button2_action() {
            // TODO: Process the button click action. Return value is a navigation
            // case name where null will return to the same page.
            System.out.println("Invoke");
            return null;
        }i don't know what is problem there if found any solution, help me.

    You need to make sure that the getter of the datatable value returns exactly the same list in the apply request values phase of the form submit as it did during the render response phase of the initial display. Only this way JSF can find out which action which row was been invoked. Alternatively you can also place the data bean in session scope (which may have more impact), or use for example Tomahawk's t:dataTable with preserveDataModel attribute set to "true".

  • Set JSF Command Button Disabled

    Hello,
    I have a JSF command button, I would like to dynamically change button disabled based on certain condition.
    I tried in the actionListener code in my managedbean
    like
    UIComponent component = event.getComponent();
    component.setRendered(false);However it makes button not visible, couldn't find setDisabled.
    How can I do this?
    Regards

    Hi,
    Basically, you can change the button status: enabled/didasled from JavaScript by changing the button css.
    You can also do this from JSF.
    The commandButton element has the disabled attribute and you can change the status depending on your condition.
    -- <h:commanButton disabled=""
    Please find an example: http://www.roseindia.net/jsf/EnableDisableButton.shtml
    If you use AJAX (ex. a4j) there is the same principle. In backing bean you can check your condition and in jsp you'll change to disabled.
    Hope this helps,
    Sergiu

  • Action link URL calling from another screen from the same web server not work

    Hi there,
    I have an action link URL calling from another screen from the same web server, used the following syntax:
    /analytics/saw.dll?Go&path=.....
    But it is not working, when open the page, it shows error message
              Oops! Google Chrome could not find analytics
    Any help? Thanks!
    Ling

    That's a +1 from me... same issue and yes, isn't inelegant or a shortcoming for some might be the cause of boldness as they rip their hair off their head so thanks in advance for keeping the refinement of the magic potions making the EA secret magic sauce... which may help stop hairloss
    Cheers!
    tfbkny

  • Can't get JSF to access managed bean methods from web page

    I'm using NetBeans 6.7.1 and Glassfish v2.1
    Having problems here can somebody please help? It is really
    frustrating because I have written apps like this before in fact I
    used one as a model to create an even simpler app and still can't get
    it to work. I ran it through the debugger and it stops in the
    constructor so it looks like the bean object is being created, but the
    setUid method and the testit method are not being entered when I click
    on the enter commandbutton. Can somebody PLEASE give me an idea as to
    what might be going on? I am totally stumped and this is holding up
    some important work I need to get done. Any help would be greatly
    appreciated:
    web.xml:
    - Show quoted text -
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <context-param>
    <param-name>com.sun.faces.verifyObjects</param-name>
    <param-value>false</param-value>
    </context-param>
    <context-param>
    <param-name>com.sun.faces.validateXml</param-name>
    <param-value>true</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
    </context-param>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>faces/welcomeJSF.jsp</welcome-file>
    </welcome-file-list>
    </web-app>
    faces-config.xml:
    <?xml version='1.0' encoding='UTF-8'?>
    <!-- =========== FULL CONFIGURATION FILE ================================== -->
    <faces-config version="1.2"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
    <managed-bean>
    <managed-bean-name>testbean</managed-bean-name>
    <managed-bean-class>com.lingosys.quoteest.testbean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
    <from-view-id>/go.jsp</from-view-id>
    <navigation-case>
    <from-outcome>correct</from-outcome>
    <to-view-id>/ok.jsp</to-view-id>
    <redirect/>
    </navigation-case>
    </navigation-rule>
    </faces-config>
    go.jsp:
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%--
    This file is an entry point for JavaServer Faces application.
    --%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>JSP Page</title>
    </head>
    <body>
    <f:view>
    <h1>JAS Generator</h1>
    <p/>
    <h:form id="testForm" enctype="multipart/form-data" >
    <p/>Both fields are required.
    <p/>Enter Test ID: <h:inputText id="pid"
    value="#{testbean.uid}" required="true"/>
    <p/><h:commandButton value="Enter"
    action="#{testbean.testit}"/>
    </h:form>
    </f:view>
    </body>
    </html>
    testbean.java:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package com.lingosys.quoteest;
    * @author mphoenix
    public class testbean {
    private String uid;
    public testbean() {
    int x=0;
    public String getUid() {
    return uid;
    public void setUid(String uid) {
    this.uid = uid;
    public String testit() {
    return "correct";
    }

    MikePhoenix wrote:
    enctype="multipart/form-data"
    Why?
    Oh, in the future please post code in code blocks. Use the CODE button to get them. Use the Preview tab to see if anything went right.

  • Command button action not calling when in subview

    i have a page that is fine when it's in it's own view...
    the command button calls a managed bean's method..
    <af:commandButton text="Call Method"
    action="#{backing_myPage.CallMethod}"
    binding="#{backing_myPage.commandButton1}"
    id="commandButton1"/>
    but when i remove the view tags and include it in a main index.jspx page
    that has a main view and a tabbed panel with showdetailitems and
    for each showdetaileditem i have a subview
    and then an include
    <f:subview id="discovered_subview" rendered="true"
    binding="#{backing_index.mypage_subview}">
    <jsp:include page="/mypage.jspx" />
    </f:subview>
    Mypage renders but the commandbutton's action is not called..
    but is called when run as a standalone page
    tia

    I also have the same problem as above. Changing the dropDown values to String does not fix it.
    I am using Netbeans Visual Web Pack.
    I drag a drop down box onto a brand new page.
    I double click the drop down box and in the processValueChange action i put System.out.println("Hello World");
    In the init() method i add 2 options to the drop down box:
    "option 1", "1"
    "option 2", "2"
    values are Strings
    I press F6 to run
    I notice that the drop down box is correctly populated.
    I change the drop down box selection
    Nothing is printed.

  • Clarification on application method calls from backing bean.

    Hi Experts ,
    In our application we are using two different ways to call application module methods from backing bean.
    allication module method name : addRowValidUnitInfo
    it has 2 parameters serialNumber,modelNumber
    1.
    BindingContainer bindings1 =
    BindingContext.getCurrent().getCurrentBindingsEntry();
    OperationBinding serialModelDetails =
    bindings1.getOperationBinding("addRowValidUnitInfo");
    serialModelDetails.getParamsMap().put("serialNumber",
    serialNumber.getValue().toString());
    serialModelDetails.getParamsMap().put("modelNumber",
    modelNumber.getValue().toString());
    serialModelDetails.execute();
    String result =serialModelDetails.getResult().toString();
    2.
    EWarrantyAdminModule appModule =(EWarrantyAdminModule)
    Configuration.createRootApplicationModule(amDef,config);
    try {
    String result = appModule.addRowValidUnitInfo(serialNumber.getValue().toString(), modelNumber.getValue().toString());
    } catch (Exception e) {
    finally {
    Configuration.releaseRootApplicationModule(appModule,true);
    Can any one tell me which one gives best performance and which one should be used in which situations.
    For me both are working fine but just want to know whcih is the best practice and which gives best performance.
    Regards
    Gayaz

    The approach 1 is the right way.
    Reasons:
    1) With Approach 2 - you are creating new ApplicationModule on the fly and release it at the end of the request. If you are invoking multiple method calls, you need to the same for each & every call.
    This is not reusing the existing application module.
    2) If the use cases which does calls for maintaining state across requests from the same client - across the application flow, Approach 2 cannot be used.
    Read this blog post from Jobinesh (which indirectly distinguishes both these approaches).
    http://jobinesh.blogspot.com/2010/04/invoking-applicationmodule-from-servlet.html
    Thanks,
    Navaneeth

  • Button action is not calling

    Hi,
    I am new to JSF.
    Here is my problem.
    I have a select one menu and command button on a page
    When ever the page loads for the first time the select one menu is loaded with the data and the button should be disabled.
    When an item is selected from the menu the button should be enabled.
    Upto this part I finished.
    Now the problem is with button.When I click the button the corresponding action method is not calling.
    If the button is enabled during page load then the action method is calling when ever I click the button.
    But I need to make the button disabled until I select an item from the
    select one menu.In this case the action method is not calling when I click the button.
    Please help me.
    Thanks in advance

    Thanks for fast response.
    Here is my jsp code:
    <script>
         function enableLoad(){
         if(document.getElementById("form1:menu1").selectedIndex==0){
         document.getElementById("form1:loadTable").value = 'true';
         else{
         document.getElementById("form1:loadTable").value = 'false';
         document.getElementById("form1").submit();
         </script>
              <h:form styleClass="form" id="form1">
              <TABLE class="tableBorder" cellspacing="10" cellpadding="10">
              <TR>
              <TD width="230" align="right">
              <SPAN class="outputtext">Select The Table To Manage:</SPAN>
              </TD>
              <TD>
              <h:selectOneMenu styleClass="selectOneMenu" id="menu1" value="#{manageReferenceTablesMB.tableValue}"
    onchange="enableLoad()">
                                  <f:selectItems value="#{manageReferenceTablesMB.tableNames}" />
                        </h:selectOneMenu>
              </TD>
              </TR>
              <TR>
              <h:inputHidden id="loadTable" value="#{manageReferenceTablesMB.loadTable}"/>
              <TD colspan="2" align="right">
              <hx:commandExButton type="submit" value="Load Table"
                                  styleClass="commandExButton" id="button1" disabled="#{manageReferenceTablesMB.loadTable}"
                                  action="#{manageReferenceTablesMB.refTable}"></hx:commandExButton>
              </TD>
              </TR>
              </TABLE>
              </h:form>
    This is the backing bean code:
    public class ManageReferenceTablesMB extends BaseMB{
         public SelectItem[] tableNames;
         public String tableValue = "-1";
    public boolean loadTable ;
         public ManageReferenceTablesMB(){
              super(SessionConstants.MANAGE_REFERENCE_TABLES);
              if (this.getFromPageDataBuffer(SessionConstants.MANAGE_REFERENCE_TABLES) == null){
              System.out.println("in constructor");
              Hashtable results = new Hashtable();
              SwqmisFrontController controller = this.getFrontController();
              results = controller.getRefTableNames();
              tableNames = buildMenu((Vector) results.get("REF_TABLE_NAMES"));
              System.out.println("added data");
              System.out.println("........."+tableValue+"..........");
              this.addToPageDataBuffer(SessionConstants.MANAGE_REFERENCE_TABLES,this);
              }else{
                   this.tableNames = ((ManageReferenceTablesMB)this.getFromPageDataBuffer(SessionConstants.MANAGE_REFERENCE_TABLES)).tableNames;
                   this.tableValue = ((ManageReferenceTablesMB)this.getFromPageDataBuffer(SessionConstants.MANAGE_REFERENCE_TABLES)).tableValue;
                   this.loadTable = ((ManageReferenceTablesMB)this.getFromPageDataBuffer(SessionConstants.MANAGE_REFERENCE_TABLES)).loadTable;
         public String refTable(){
              System.out.println("IN REF TABLE");
              System.out.println("....."+tableValue+".......");
              Hashtable results = new Hashtable();
              SwqmisFrontController controller = this.getFrontController();
              results = controller.getRefTable(getDisplayText(tableNames,tableValue));
              if(results!=null && results.size()>1)
              System.out.println("success");
              else
              System.out.println("failure");
              return "success";
         * @return Returns the tableNames.
         public SelectItem[] getTableNames() {
              return tableNames;
         * @param tableNames The tableNames to set.
         public void setTableNames(SelectItem[] tableNames) {
              this.tableNames = tableNames;
         * @return Returns the tableValue.
         public String getTableValue() {
              return tableValue;
         * @param tableValue The tableValue to set.
         public void setTableValue(String tableValue) {
              this.tableValue = tableValue;
         * @return Returns the loadTable.
         public boolean isLoadTable() {
              return loadTable;
         * @param loadTable The loadTable to set.
         public void setLoadTable(boolean loadTable) {
              this.loadTable = loadTable;
    In the above backing bean code the loadTable value is false.
    So under this condition the action method is calling.B'cause the button is in enable state even there is no section in the menu.
    If I make loadTable=true then the action button is in disabled state until the menu item is selected. But the action method is not executing in this case.
    Thanks.

  • Jsf command button

    hi
    i have a command button as
    <f:view>
    <html>
    <body>
    <h:form id="form1">
    <h:outputText value="BuyerId :" />
         <h:selectOneMenu id="buyerid" value = "#{findprg.buyerid}" onchange = 'buyerOnChange()'>
    <f:selectItems value="#{global.buyersList}" />
    </h:selectOneMenu>
    <h:outputText value="Department :" />
    <h:selectOneMenu id='departmentid' value="#{findprg.deptid}">
    <f:selectItems value="#{global.departmentList}" />
    </h:selectOneMenu>
    <h:commandButton value="Find Program" action="#{findprg.loadData}"/>
    <h:dataTable value="#{findprg.programList}" var="row" border="1" cellspacing="1">
    <h:column><f:facet name="header"><h:outputText value = "programId"/></f:facet><h:outputText value="#{row.programId}"/></h:column>
    <h:column><f:facet name="header"><h:outputText value = "programName"/></f:facet><h:outputText value="#{row.programName}"/></h:column>
    <h:column><f:facet name="header"><h:outputText value = "buyerId"/></f:facet><h:outputText value="#{row.buyerId}"/></h:column>
    <h:column><f:facet name="header"><h:outputText value = "departmentId"/></f:facet><h:outputText value="#{row.departmentId}"/></h:column>
    </h:dataTable>
    </h:form>
    </body>
    </html>
    </f:view>
    Web.xml
    <managed-bean>
    <managed-bean-name>findprg</managed-bean-name>
    <managed-bean-class>com.poc.backingBean.FindProgram</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    My bean is
    public class FindProgram {
         private List<Program> programList = new ArrayList<Program>();
         private int buyerid;
         private int deptid;
         private int seasonid;
         private int brandid;
         private int classid;
         public String loadData() {
              System.out.println("Entering");
              DefineProgramMaintenanceFacade defineprogramfacade = AsConnector.getProgramMaintanenceFacadeBean();
              programList = defineprogramfacade.getProgramList(buyerid,deptid);
              System.out.println("exit");
              return null;
    But the method loadData is not called
    can anyone help me in this regard?
    Regards

    There may be a validation or conversion error occurred. Add <h:messages /> to the page to take note of them. Since JSF RI 1.2 it should also be logged to the stdout, read the application server logs.

  • af:poll stops polling on bean method call

    Using JDev 10.1.3.5.0. Yes, it's archaic.
    I've spent the past two days trying to get a <af:poll> component to work with no success. I've gone through tutorials and gotten them to work, but my personal use case will not.
    A dialog window opens. When this dialog loads, a poll component begins refreshing a progress indicator every 2 seconds. This works; I can see the refresh happening. Inside this dialog, a user then clicks a "Start" button, triggering an actionEvent method.
        public void startAction(ActionEvent actionEvent) {
            // initialize progress indicator's range model to 0
            this.simpleBoundedRangeModel.start(actionEvent);
            // Begin performing a business process.
            ManagementDashboardExport pbm = (ManagementDashboardExport)EL.get("#{ManagementDashboardExport}");
            pbm.exportDashboard();
        }In that bean, a process runs which then updates the progress indicator's model
        public String exportDashboard(){
            private PollingBackingBean pbm = (PollingBackingBean)EL.get("#{PollingBB}");
            // do a bunch of work and at a certain milestone, set that 20% of the work has been done.
            pbm.getSimpleBoundedRangeModel().setValue(20);
            // continue doing work
         }The problem is that at the point exportDashboard() begins, the polling quits! The program keeps running and eventually finishes, but the progress indicator never refreshes.
    How can a file download/upload process work, but my process not? This seems like some kind of threading issue. I'm trying to show the progress of a running process. Any ideas on how I can get this to work?
    Thanks,
    Will
    PS: The .jspx code and PollingBackingBean class
            <af:form id="f1">
              <af:panelGroup id="pgl1">
                <af:panelGroup id="pgl2" layout="horizontal">
                  <af:commandButton text="Start" id="cb1" partialSubmit="true" actionListener="#{PollingBB.startAction}"/>
                  <af:objectSpacer width="10" height="10" id="s1"/>
                  <af:commandButton text="Cancel" id="cb2" partialSubmit="true" actionListener="#{PollingBB.cancelAction}"/>
                </af:panelGroup>
                <af:objectSpacer width="10" height="10" id="s2"/>
                <af:poll interval="2000" id="poll" pollListener="#{PollingBB.pollMe}" binding="#{PollingBB.pollComponent}" rendered="true"/>
                <af:progressIndicator id="pi1" rendered="true" partialTriggers="poll" value="#{PollingBB.simpleBoundedRangeModel}"/>
              </af:panelGroup>
            </af:form>
    public class PollingBackingBean {
        SimpleBoundedRangeModel simpleBoundedRangeModel;
        private int pollInterval = -1;
        private CorePoll pollComponent;
        public void startAction(ActionEvent actionEvent) {
            this.simpleBoundedRangeModel.start(actionEvent);
            ManagementDashboardExport pbm = (ManagementDashboardExport)EL.get("#{ManagementDashboardExport}");
            pbm.exportDashboard();
        public void cancelAction(ActionEvent actionEvent) {
            this.pollInterval = -1;
            this.pollComponent.setRendered(false);
            this.simpleBoundedRangeModel.cancelProcess(actionEvent);
            AdfFacesContext.getCurrentInstance().addPartialTarget(this.pollComponent);
        public void pollMe(PollEvent pollEvent) {
            if (this.simpleBoundedRangeModel != null) {
                if (this.simpleBoundedRangeModel.getValue() < this.simpleBoundedRangeModel.getMaximum()) {        
                    System.out.println("Polling Event Triggered");
                } else {
                    this.pollInterval = -1;
                    AdfFacesContext.getCurrentInstance().addPartialTarget(this.pollComponent);
                    this.simpleBoundedRangeModel.setValue(0L);
        public SimpleBoundedRangeModel getSimpleBoundedRangeModel() {
            if (this.simpleBoundedRangeModel == null)
                this.simpleBoundedRangeModel = new SimpleBoundedRangeModel();
            return this.simpleBoundedRangeModel;
        public void setPollInterval(int pollInterval) {
            this.pollInterval = pollInterval;
        public int getPollInterval() {
            return pollInterval;
        public void setPollComponent(CorePoll pollComponent) {
            this.pollComponent = pollComponent;
        public CorePoll getPollComponent() {
            return pollComponent;
    }

    I am using a recent version but this is a thread that Google took me to when searching "start stop af:poll"
    I had my Eureka moment yesterday and have everything working now but maybe for the benefit of others I will describe my case here:
    What I want to do is start a background task that performs some long running task taking several minutes.
    This task updates a progress number in a DB table while it is progressing.
    During this task I want to popup a modal dialog with a progress bar.
    In order to update the progress bar I want to client to poll and execute and read to iterator for the VO containing the record with the progress percent.
    When the task is complete I want polling to stop.
    My solution consists of an jspx page and viewScope Bean
    on the jspx page:
    I have an af:commandButton to start the task with id="cbstart" and an actionListener in a Bean
    an af:popup containing and af:dialog containing an af:progressIndicator  bound to a BoundedRangeModel in the Bean
    an af:poll id="poll" pollListener set to a method named poll in the Bean also bind it to a poller object in the Bean.
    Set the interval to -1 so it starts off disabled.
    Now look at this from the point of view of what initiates work there are only 2 types of actions:
    1 The push on the command button
    2 The poll events
    1. When the command button is pushed
    * start the actual task
    * start the poller
    * popup the dialog
    So in the bean this looks like:
        public void onCbStart(ActionEvent actionEvent) {
            startTask(); // kicks of background task
            // popup the popup
            RichPopup.PopupHints hints = new RichPopup.PopupHints();
            popup.show(hints);
            // enable the popup
            poll.setInterval(2000);
    This was at first not working for me because I did not really understand PPR. Polling is done by the browser. On the server side the poll object is now has its interval property set to 2000 but in the client it does not know about it yet. We should have made sure we set cbstart as a partialTrigger
    of the ad:poll so the client side poll object will update its state after the press of the command button.
    2, Now on the poll event ifself in the bean add code like this:
       public void poll(PollEvent pollEvent) {
            // re-execute query so we can get current progress value
            DCBindingContainer bc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
            OperationBinding exe = bc.getOperationBinding("ExecuteWithParams");
            exe.execute();
            // get current progress value
            AttributeBinding obj = (AttributeBinding)bc.getControlBinding("Progress");
            BigDecimal iv = (BigDecimal)obj.getInputValue();
           // Update progress in our BoundedRangeModel
           rm.setProgress(iv.intValue());
           // If we reach 100% we are done
            if ( rm.getValue() >= rm.getMaximum() ) {
                // stop polling
                poll.setInterval(-1);           
    So what client side components may require updates after a poll?
    1 - progressIndicator
    So we add poll to the partial triggers of the af:progressIndicator
    Again I was baffled at first why the polling did not stop. Then I finally figured out that the poll object itself needs to have poll as a partial trigger since in the poll we change its interval to -1 in order to disable it and it need to read to back on the client
    So partial triggers for the af:poll need to be "cbstart poll"
    Lessons learned:
    1 - If you need to have more than 1 thing happen from a button press like for example, start solve, popup, start polling, you need to do this through a bean and not just using bindings.
    2 - Think about the 'starting' actions on the page and all the resulting parts of the page that may have their state changed resuling from that initial event and set your partial triggers based on that.
    Jeroen

  • JSF Command Button and Command Links

    The main page of my JSF application has a Save button and Command Links. After making any changes on the main page the user should click Save before using any of the Links. Most of the time almost all users do this. However, some users are making changes then clicking a Link, thereby losing their changes.
    I could always execute my save method in the backing bean when a link is clicked, but, most of the time this would be doing a lot of processing which usually would not be necessry.
    Is their some way to check if any changes have been made and then doing the save only when necessary?
    Regards,
    Al Malin

    Anybody?
    What would be beneficial is something like this. If somehow it could be determined if any of the JSF fields on the page were modified. Then, in the backing bean method that handles the ActionEvents for the links, I would check if changes were made and, if so, call my save method.
    In other words is it possible to determine, in the backing bean, whether or not JSF fields have changed?
    Regards,
    Al Malin

  • JSF Problem invoking backing bean method

    I want a backing bean method to be invoked when the submit button is clicked but for some strange reason the method is not getting invoked any Help in this regards would be great.
    I am able to properly get the values from database and display on the page , after the user types in some more additional information like password , hint question the form has to be submitted when clicked on the submit button..
    Register.jsp
    <body>
         <f:view>
         <h:graphicImage url="/header.jpg"></h:graphicImage>
               <br><h:form id="user">
                        <table>
                        <tr>
                             <td>
                                  <h:outputLabel for="" value="uUser Name:" styleClass="orderlabelcell"></h:outputLabel></td><td>
                                  <h:inputText onblur="JavaScript:doSubmit();" value="#{registerFormBean.userName}" id="userName"></h:inputText>
                             </td>
                        </tr>
                        <tr>     
                             <td>
                             <h:outputLabel for="" value="First Name:" styleClass="orderlabelcell"></h:outputLabel></td><td>
                             <h:inputText value="#{registerFormBean.firstName}" id="firstName"></h:inputText></td>
                        </tr>
                        <tr>     
                             <td><h:outputLabel for="" value="Middle Name:" styleClass="orderlabelcell"></h:outputLabel></td><td>
                             <h:inputText id="middleName" value="#{registerFormBean.middleName}"></h:inputText></td>
                        </tr>
                        <tr>     
                             <td><h:outputLabel for="" value="Last Name:" styleClass="orderlabelcell"></h:outputLabel></td><td>
                             <h:inputText id="lastName" value="#{registerFormBean.lastName}"></h:inputText></td>
                        </tr>
                        <tr>
                             <td>
                                  <h:outputLabel for="" value="Password:" styleClass="orderlabelcell"></h:outputLabel></td><td>
                                  <h:inputText id="password" value="#{registerFormBean.password}"></h:inputText>
                             </td>
                        </tr>
                        <tr>     
                             <td><h:outputLabel for="" value="Re-type Password:" styleClass="orderlabelcell"></h:outputLabel></td><td>
                             <h:inputText></h:inputText></td>
                        </tr>
                        <tr>     
                             <td><h:outputLabel for="" value="Password Hint Question:" styleClass="orderlabelcell"></h:outputLabel></td><td>
                             <h:inputTextarea id="hintQuestion" value="#{registerFormBean.hintQuestion}"></h:inputTextarea></td>
                        </tr>
                        <tr>     
                             <td><h:outputLabel for="" value="Password Hint Answer:" styleClass="orderlabelcell"></h:outputLabel></td><td>
                             <h:inputTextarea id="hintAnswer" value="#{registerFormBean.hintAnswer}"></h:inputTextarea></td>
                        </tr>
                        <tr>     
                             <td>
                                  <h:commandButton id="submit" value="Submit" type="submit" action="#{registerFormBean.saveUser}"/>
                                  <h:commandButton id="Reset" value="Reset" type="reset"/>
                                  </td>
                        </tr>
                        </table>
                   </h:form>
         </f:view>
    </body> 
    RegisterFormBean.java
      package services;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import dao.DatabaseHandler;
    import model.User;
    public class RegisterFormBean {
    User selectedUser;
    String userName;
    String firstName;
    String middleName;
    String lastName;
    String password;
    String hintQuestion;
    String hintAnswer;
    String errMsg;
    private DatabaseHandler dbHandle;
    public RegisterFormBean() {
         javax.faces.context.FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
         javax.faces.application.Application app = context.getApplication();
         dbHandle = (DatabaseHandler)app.createValueBinding("#{databaseHandler}").getValue(context);
    public void setUserDetails() {
         try{
              System.out.println("gettting Details for user: "+userName);
              selectedUser = (User)dbHandle.getUser(userName);
         catch (SQLException e) {
              errMsg = "Problem gettting records";
    public String getUserName() {
         if(null!=userName){
              setUserDetails();
         if(null!=selectedUser)
              return selectedUser.getLoginName();
         else
         return "";
    public void setUserName(String userName){
         this.userName = userName;
    public String getFirstName() {
         if(null!=selectedUser)
              return selectedUser.getFirstName();
         else
         return "";
    public void setFirstName(String firstName) {
         System.out.println("in setFirst name");
         this.firstName = firstName;
    public String getMiddleName() {
         if(null!=selectedUser)
              return selectedUser.getMiddleName();
         else
         return "";
    public void setMiddleName(String middleName) {
         System.out.println("in set middle name...");
         this.middleName = middleName;
    public String getLastName() {
         if(null!=selectedUser)
              return selectedUser.getLastName();
         else
         return "";
    public void setLastName(String lastName) {
         System.out.println("in set last name....");
         this.lastName = lastName;
    public String getPassword() {
         return password;
    public void setPassword(String password) {
         if(null!=password){
              System.out.println("$$$$$$$$$$$$ setting password.."+password);
              selectedUser.setPassword(password);
    public String getHintQuestion() {
         return hintQuestion;
    public void setHintQuestion(String hintQuestion) {
         if(null!=hintQuestion){
              System.out.println("#########  Hint Question "+hintQuestion);
              selectedUser.setHintQuestion(hintQuestion);
    public String getHintAnswer() {
         return hintAnswer;
    public void setHintAnswer(String hintAnswer) {
         if(null!=hintAnswer){
              System.out.println("@@@@@@@  Hint Answer"+hintAnswer);
              selectedUser.setHintQuestion(hintAnswer);
    public String saveUser(){
         String flag = "";
         System.out.println("IN registerUser Method....");
         try{
              if(null!=selectedUser){
                   flag = dbHandle.registerUser(setUserDefaults(selectedUser));
         catch(SQLException se){
         flag="fail";
         System.out.println("FAILED DUE TO THE EXCEPTION :- "+se.getMessage());
         errMsg = "Unable to Register the User...";
         return flag;
    public User setUserDefaults(User user){
         System.out.println("SETTING USER DEFAULTS.....");
         user.setActive(true);
         user.setLoginType("False");
         user.setCreatedUserName("SOMEUSERNAME");
         user.setSecIdFunctionGroup(17);
         user.setChallangeWord("CHANGE IT");
         user.setTrusted(false);
         user.setUserTypeIdTypeOf(1);
         user.setChangePwdNextLogin("False");
         user.setLoginIsDisabled(false);
         user.setPasswordNeverExpires(false);
         user.setThinWorkOrder(false);
         user.setCurrencyTypeId(2);
         return user;
    I am able to fetch the details from Database and display on the page so DAO is working properly hence not copying here
    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>
      <managed-bean-name>databaseHandler</managed-bean-name>
      <managed-bean-class>dao.DatabaseHandler</managed-bean-class>
      <managed-bean-scope>application</managed-bean-scope>
    </managed-bean>
    <managed-bean>
      <managed-bean-name>registerFormBean</managed-bean-name>
      <managed-bean-class>services.RegisterFormBean</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
      <from-view-id>/Register.jsp</from-view-id>
      <navigation-case>
       <from-outcome>success</from-outcome>
       <to-view-id>/Success.jsp</to-view-id>
      </navigation-case>
    </navigation-rule>
    </faces-config>

    A conversion or validation error may have been occurred. Add <h:messages/> to the page to note them all. If you're using at least Sun Mojarra 1.2, then you should be able to note them all in the application server logs.

  • Solution to Button Action not being called in IE

    All,
    Thought I'd post a solution to a problem I had recently. I have seen variations on a theme elsewhere on the net.
    IDE: Java Studio Creator 2, Update 1.
    Problem: The button action associated with a button component on a jspx page is not called when using IE 6, but is called using M. Firefox 1.5.
    Background: The jspx page is a combination of one core jsp page and four jsp fragments (header, main nav bar, module nav bar, authorization code). Several components are present on the core jsp page (layout components, table, buttons), several on the header, main nav bar, module nav bar fragments (images, hyperlinks, text), JSTL and a lonesome form on the authorization fragment. You can see where I'm going....
    Solution: The problem was with the authorization fragment. The authorization fragment is meant to be dropped on pages that I want to protect from users without the authorized role, perhaps by these users trying to navigate to it by URL manipulation. I added some JSTL code to specifically look at the role authorization for the current session user. If not in that role, they are redirected to the home page. Navigation links are secured by similar authorization using the rendered property bound to session data. The form was the problem. Unfortunately, I didn't give much thought to the additional component I would need on the fragment. I had to add something so I picked a layout one. The IDE appears to require a component. To correct the problem, I simply set the rendered property to "false". IE 6 now works fine, M. Firefox 1.5 was always happy. Code example below...
    Code Pre:
    <?xml version="1.0" encoding="UTF-8"?>
    <div style="-rave-layout: grid; width: 400px; height: 200px" xmlns:c="http://java.sun.com/jstl/core" xmlns:f="http://java.sun.com/jsf/core"
        xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui">
        <c:if test="${SessionBean1.monitor==false}">
            <c:redirect url="/faces/Welcome.jsp"/>
        </c:if>
        <ui:form binding="#{MonCheck.form1}" id="form1" />
    </div>
    Code Post:
    <?xml version="1.0" encoding="UTF-8"?>
    <div style="-rave-layout: grid; width: 400px; height: 200px" xmlns:c="http://java.sun.com/jstl/core" xmlns:f="http://java.sun.com/jsf/core"
        xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui">
        <c:if test="${SessionBean1.monitor==false}">
            <c:redirect url="/faces/Welcome.jsp"/>
        </c:if>
        <ui:form binding="#{MonCheck.form1}" id="form1" rendered="false"/>
    </div>

    Hi there,
    Great to know you were able to fix your problem. Thanks for posting the solution as well, Im sure It'll help the community.
    Thanks
    K

Maybe you are looking for