Which component invoked bean method

When a form is submitted and validation errors occur, I'd like to indicate the component that caused the validation error with a different style.
For example:
JSF page:
            <h:form id="form">
                <h:panelGrid columns="2">
                    <t:outputText value="Name"/>
                    <h:panelGroup>
                        <t:inputText value="#{UserBean.newUser.name}" id="name" required="true" style="#{UserBean.styleBorder}" />
                        <h:message for="name" style="color:red;text-decoration:overline" />
                    </h:panelGroup>
                    <t:outputText value="First name" />
                    <h:panelGroup>
                        <t:inputText value="#{UserBean.newUser.firstname}" id="firstname" required="true" />
                        <h:message for="firstname" style="color:red;text-decoration:overline" />
                    </h:panelGroup>
                    <h:outputText value="" />                  
                    <t:commandButton action="#{UserBean.addUser}" value="Add user" />
                </h:panelGrid>
            </h:form>UserBean code:
    public String getStyleBorder() {
        FacesContext context = FacesContext.getCurrentInstance();
        if (context.getMessages("form:name").hasNext() == true) {  //Er zijn messages aanwezig voor deze component
            return "border-style:solid;border-color:#FF0000";
        else {
            return "";
    }In this example, when the user didn't fill in the name component correctly, a red border is drawed at the name-component.
In the context.getMessages method in the UserBean whoever, I need to hardcode the id of the component that needs to be checked for validation errors.
Therefore, I would need a getStyleBorder method for each component of the form.
Like this:
JSF page:
            <h:form id="form">
                <h:panelGrid columns="2">
                    <t:outputText value="Name"/>
                    <h:panelGroup>
                        <t:inputText value="#{UserBean.newUser.name}" id="name" required="true" style="#{UserBean.styleBorderName}" />
                        <h:message for="name" style="color:red;text-decoration:overline" />
                    </h:panelGroup>
                    <t:outputText value="First name" />
                    <h:panelGroup>
                        <t:inputText value="#{UserBean.newUser.firstname}" id="firstname" required="true" style="#{UserBean.styleBorderFirstName}" />
                        <h:message for="firstname" style="color:red;text-decoration:overline" />
                    </h:panelGroup>
                    <h:outputText value="" />                  
                    <t:commandButton action="#{UserBean.addUser}" value="Add user" />
                </h:panelGrid>
            </h:form>UserBean code:
    public String getStyleBorderName() {
        FacesContext context = FacesContext.getCurrentInstance();
        if (context.getMessages("form:name").hasNext() == true) {  //Er zijn messages aanwezig voor deze component
            return "border-style:solid;border-color:#FF0000";
        else {
            return "";
    public String getStyleBorderFirstName() {
        FacesContext context = FacesContext.getCurrentInstance();
        if (context.getMessages("form:firstname").hasNext() == true) {  //Er zijn messages aanwezig voor deze component
            return "border-style:solid;border-color:#FF0000";
        else {
            return "";
    }This causes a lot of duplicate code.
Is it possible to have only 1 getStyleBorder method that can handle the style for every component in the form?
Is there a way to get the id of the component that invoked the getStyleBorder method?

I'd to implement a PhaseListener for that. Listen on the beforePhase of PhaseId.RENDER_RESPONSE, get all client IDs with facesmessages by FacesContext#getClientIdsWithMessages(), retrieve the appropriate UIComponent for the client ID by UIViewRoot#findComponent() and set its style.

Similar Messages

  • Need to invoke bean method prior to initial page

    I have a web application with a default welcome page (index.jsp) that automatically forwards to a page with JSF tags in it (home.jsp). I use:
    <jsp:forward page="home.faces" />to accomplish this. This works fine for rendering the JSF tags in the page as long as the page does not need data from the server.
    However, this is not the case. I need to have a backing bean method invoked as follows:
      // ActionListener handler.
      public void retrievePagerList(ActionEvent event) {
        if (logger.isDebugEnabled()) {
          logger.debug("In retrievePagerList method of backing PagerBean.");
        try {
          setPagers(PagerDAO.selectAll());
        catch (SQLException e) {
          logger.error("Error retrieving list of pagers: ", e);
      public void setPagers(List pagers) {
        this.pagers = pagers;
        if (logger.isDebugEnabled()) {
          logger.debug("Number of pagers set: " + pagers.size());
      }I want to load a list of objects from the database so that the initial page shown to the users has a list of pagers displayed as follows:
    <f:view>
      <h:form>
      <h:dataTable styleClass="dataTable"
                   value="#{pagerBean.pagers}"
                   var="pager">
        <h:column>
        <h:commandLink id="editPager"
                       title="Edit Pager"
                       value="Edit"
                       action="edit"
                       actionListener="#{pagerBean.editPager}">
        </h:commandLink>
        </h:column>
        <h:column>
          <h:outputText value="#{pager.pagerType}"/>
        </h:column>
        <h:column>
          <h:outputText value="#{pager.pagerName}"/>
        </h:column>
      </h:dataTable>
      </h:form>
    </f:view>How can I accomplish this? I cannot seem to find a way to have a backing bean method invoked to put objects into the request (or session scope) in order for the initial JSP to display properly.

    jsf 1.2 will contains beforePhaseListener attribute for f:view that allows to call some code before page is loaded. For the current jsf version, it is usually recommended to register your own phase listener that is invoked "before Render Response" phase.
    Sergey : jsfTutorials.net

  • How to invoke bean method after query executed?

    Jdeveloper 11.1.1.2:
    I have a bean that backs a JSF page.
    The bean has a method that shows/hides certain GUI components based on the values of other components.
    I would like to invoke this method automatically after the page has been fully loaded.
    I tried invoking the method in the AfterPhase of the f:view and at bean construction time. Both approaches failed.
    I think I need a listener that gets invoked after the query has been executed.
    Any idea?
    thanks

    Hi,
    if the bean is a backing bean and it is supposed to hide components, then why don't you create a reference of the components to the backing bean so that the displayed property is dynamically evaluated ? Sounds like this is what you want to do
    Frank

  • Problem while invoking webservice-method in client-code

    Hi,
    I had written webservice-client-code (using uddi-ext.jar, as i am using uddi for publishing webservices.) which is invoking webservice method successfully with complex datatypes(both for return type and input paramters).
    But while calling following webservice-method from my client-code:
    public ComplexType[] getData(String[] p_str1, String[] p_str2)
    it is throwing exception
    The Exception is:
    [ERROR] - 27 Mar 2007 12:34:38 -failed to invoke operation 'getData' due to an error in the soap layer (SAAJ); nested exception is: Message[failed to deserialize xml:weblogic.xml.schema.binding.DeserializationException: mapping lookup failure. type=['java:language_builtins.lang']:ArrayOfString schema context=TypedSchemaContext{javaType=[Ljava.lang.String;}]
    Although I had done correct registration of mapping of ArrayOfString in client-code:
    registry = m_Service.getTypeMappingRegistry();
                   m_TypeMapping = registry.getTypeMapping(SOAPConstants.URI_NS_SOAP_ENCODING );
                   m_TypeMapping.register( ArrayOfStringHolder.class,
    new QName( "java:language_builtins.lang", "ArrayOfString" ),
    new ArrayOfStringCodec(),
    new ArrayOfStringCodec());
    But some how it doesnt works.
    I had searched on google as well but didnt find any reliable solutions.
    Please advice.
    Edited by meetmrdeepak at 03/27/2007 2:43 AM
    Edited by meetmrdeepak at 03/27/2007 2:45 AM

    See item A.1 of the [RMI FAQ|http://java.sun.com/j2se/1.5.0/docs/guide/rmi/faq.html].

  • How to find the class name, the location from where it invoked a method

    Hi,
    I have a class A. The caller calls A.someMethod(), whenever this method is invoked, I want to find out the caller info, which class invoked this method, from where this class was loaded (may be the jar file name). Any help will be appreciated.
    Thanks.

    However since version 1.4 there is an easier way to extract that information from the Throwable:
    java.lang.Throwable
    public StackTraceElement[] getStackTrace()
    Provides programmatic access to the stack trace information printed by printStackTrace(). Returns an array of stack trace elements, each representing one stack frame.

  • How to realize timeout while invoking a method in remote sesssion bean using my session bean running on wls5.1

    I am using WL5.1 SP11 on a project. I have a stateless session bean inside which
    I will invoke a method defined in another stateless session bean in a remote weblogic
    server 5.1. The performance of the remote server is very low and sometimes when
    I invoke the method through RMI, I got to wait for a long time. So I want to set
    a timeout for my session bean while doing RMI call. The only parameter I could
    find in weblogic-ejb-jar.xml is the "transaction-timeout", but even if I set transaction
    attribute for my session bean, it always block there to wait for the response
    from the remote session bean. The configuation did not work.
    Is there any other solutions to my problem? Please give me some advice if anyone
    has experience on it, Thank you very much.

    I am using WL5.1 SP11 on a project. I have a stateless session bean inside which
    I will invoke a method defined in another stateless session bean in a remote weblogic
    server 5.1. The performance of the remote server is very low and sometimes when
    I invoke the method through RMI, I got to wait for a long time. So I want to set
    a timeout for my session bean while doing RMI call. The only parameter I could
    find in weblogic-ejb-jar.xml is the "transaction-timeout", but even if I set transaction
    attribute for my session bean, it always block there to wait for the response
    from the remote session bean. The configuation did not work.
    Is there any other solutions to my problem? Please give me some advice if anyone
    has experience on it, Thank you very much.

  • Backing Bean method not invoked - h:selectOneRadio

    Hi,
    I am trying to invoke a method in the backing bean when a radio button is selected, but for some reasons the method is not getting invoked, any idea why is it so? copying the code for reference.
    I have a command button in this jsp which when clicked is fetching the records(from the backing bean) perfectly and a radio button for each of the record so user can select any one of the records listed.
    example.jsp
    <%@ page language="java" pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
         <base href="<%=basePath%>">
         <title>My Page</title>
         <meta http-equiv="pragma" content="no-cache">
         <meta http-equiv="cache-control" content="no-cache">
         <meta http-equiv="expires" content="0">   
         <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
         <meta http-equiv="description" content="sample List">
         <!--
         <link rel="stylesheet" type="text/css" href="style.css">
         <link rel="stylesheet" href="styleNN.css" type="text/css">
         -->
         </head>
    <body>
         <f:view>
              <h:form id="contacts">
              <table width="200" border="0" title="sample List" style="border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-style: solid" bgcolor="#F0F0F0" cellpadding="2" cellspacing="2">
                   <h:outputLabel value="Product List:" style="font-family: Verdana, Arial, Sans-Serif; font-size: 14px; color: Black; font-weight: bold; font-style: normal; width: 198px" styleClass="bigfieldcell"></h:outputLabel>
                          </table>
              <br>
         <div style="height: 400px; overflow: auto">
                   <h:dataTable border="1" value="#{contactsBean.contactsList}" var="contact" bgcolor="#EEEEEE" frame="box" styleClass="orderlabelcell" cellpadding="3">
                   <h:column>
                             <f:facet name="header">
                                  <h:outputText value="Select to Edit"/>
                             </f:facet>
                                  *<h:selectOneRadio valueChangeListener="#{contactsBean.test}">*
                    *               <f:selectItem itemValue="#{contact}" />*
                *               </h:selectOneRadio>*               </h:column>
                        <h:column>
                             <f:facet name="header">
                                  <h:outputText value="Category"/>
                             </f:facet>
                             <h:inputText value="#{contact.category}" style="border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-color: #FFFFFF; border-top-color: #FFFFFF"></h:inputText>
                        </h:column>
                        <h:column>
                             <f:facet name="header">
                                  <h:outputText value="Location"/>
                             </f:facet>
                             <h:outputText value="#{contact.location}"></h:outputText>
                        </h:column>
                        <h:column>
                             <f:facet name="header">
                                  <h:outputText value="Problem Type"/>
                             </f:facet>
                             <h:outputText value="#{contact.problemType}"></h:outputText>
                        </h:column>
                        <h:column>
                             <f:facet name="header">
                                  <h:outputText value="Problem Details"/>
                             </f:facet>
                             <h:outputText value="#{contact.problemDetails}"></h:outputText>
                        </h:column>
                        <h:column>
                             <f:facet name="header">
                                  <h:outputText value="Contact"/>
                             </f:facet>
                             <h:outputText value="#{contact.contact}"></h:outputText>
                        </h:column>
                   </h:dataTable>
                   </div>
                   </h:form>
              </f:view>
    </body>
    </html>
    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>contactsBean</managed-bean-name>
      <managed-bean-class>services.ContactsBean</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
      <managed-bean-name>contactsDatabaseHandler</managed-bean-name>
      <managed-bean-class>dao.ContactsDatabaseHandler</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    </faces-config>
    ContactsBean.java
    package services;
    import java.util.ArrayList;
    import java.util.Hashtable;
    import java.util.List;
    import javax.faces.context.FacesContext;
    import javax.faces.event.AbortProcessingException;
    import javax.faces.event.ValueChangeEvent;
    import javax.faces.model.SelectItem;
    import sun.security.action.GetLongAction;
    import dao.ContactsDatabaseHandler;
    import model.Contact;
    public class ContactsBean {
         private String selectedLocation;
         private List locationList;
         private String selectedProblemType;
         private List problemTypeList;
         private List contactsList;
         private ContactsDatabaseHandler dbHandler;
         private String address;
         private Hashtable region;
         private Contact selectedContact;
         public void test(ValueChangeEvent event)throws AbortProcessingException {
              System.out.println("In Backing Bean : test method.... ");
    }Thanks in Advance

    The valueChangeListener runs at the server side. You need to submit the form to the server side to invoke the valueChangeListener. There is no client side magic like Javascript.
    To submit the parent form on change of the dropdown, just add the following attribute with a piece of Javascript to the h:selectOneMenu:onchange="this.form.submit()"

  • Refresh iterator after invoking backing bean method

    Hi guys,
    I 'm using jdev 11.1.1.1.0.
    I have a jspx page which displays a table with data. I've succeedeed on not displaying data of the table on initial rendering with this code (it's my will) :
    <iterator Binds="ProjetsActifsLectureSeule_extend1" RangeSize="25"
    DataControl="AppModuleCodesProjetsDataControl"
    id="ProjetsLectureSeule1Iterator" RefreshCondition="#{!adfFacesContext.postback}"/>
    When i click a button on the page i want the table to display all datas. I've coded a backingbean method for that (named displayall) :
    public void displayAll(ActionEvent actionEvent) {
    ((DCIteratorBinding)getBindings().get("ProjetsLectureSeule1Iterator")).executeQuery();
    AdfFacesContext.getCurrentInstance().addPartialTarget(table3); // table3 contains the datas i want to be refreshed
    The method is executed but no datas are displayed like in the initial rendering of the page.
    What is wrong with my code?
    Thanks

    Yes Amseth,
    i want that datas of a query aren't displayed (it's a table component) on the initial rendering of the page.
    But i want there are displayed when i reexecute the query from a backing bean method.

  • ***How to Invoke backing bean method by DOUBLE-CLICK the table ROW!!***

    Hi,
    How can I collect the selected row value & navigate to next page by DOUBLE-CLICK the result table row.
    My application got searchResult page where I am displaying the list of user in result table. Then selecting any one row and navigating to master details page by clicking the continue button. Button Action method will collect the selected row userID which I am forwarding to the masterDetails page.
    Same functionality I want to do by double click the row instead of clicking the button!!. I want to trigger the backing bean method if the user double click the row basically. Please help me in this how to do this?
    Current button action method:
    *public String userSelected() {*
    FacesCtrlHierNodeBinding binding = (FacesCtrlHierNodeBinding) searchResultTable.getSelectedRowData();
    currentRow = binding.getRow();
    selectedNetID = (String) currentRow.getAttribute("netid");
    System.out.println("selectedNetID -->"+selectedNetID);
    requestContext.getPageFlowScope().put("netid",selectedNetID);
    return "continue";
    *}*

    Puthanampatti ,
    Yes, I am using the same. Below is my code. I am trying to get the object of the MAIN jspx page region (where I am displaying the fragments) and refresh the one. But cant able to get the object for the region it is returning null. without refresh seems the navigation wont work.
    public void doDbClick(ClientEvent clientEvent) {
    FacesCtrlHierNodeBinding binding = (FacesCtrlHierNodeBinding) searchResultTable.getSelectedRowData();
    currentRow = binding.getRow();
    selectedNetID = (String) currentRow.getAttribute("netid");
    System.out.println("selectedNetID -->"+selectedNetID);
    requestContext.getPageFlowScope().put("netid",selectedNetID);
    try{
    FacesContext facesCtx = FacesContext.getCurrentInstance();
    NavigationHandler nh = facesCtx.getApplication().getNavigationHandler();
    nh.handleNavigation(facesCtx, "", "continue");
    System.out.println("region obj -->" +facesCtx.getViewRoot().findComponent("advse1"));
    // Refresh the current region; advse1 is the id of the region component inside jspx page
    AdfFacesContext.getCurrentInstance().addPartialTarget(facesCtx.getViewRoot().findComponent("advse1"));
    catch(Exception e){
    System.out.println("Error is: " +e);
    Is this correct coding to get the region object?? actually the "result table" and "Master details" are 2 different fragments which are linked with task-flow and the task flow is part of main jspx page as a region. I am using that region ID to get the obj, but cant able to get so....!!! any idea

  • About backing bean method's invokation

    Hi,
    I have a backing bean method binded to a component:
    <af:selectOneChoice value="#{bindings.managerId.inputValue}"
    label="Manager" valign="middle"
    binding="#{backing_searchDocuments.managersList}"
    valuePassThru="true" immediate="false"
    rendered="#{bindings.ListManagersIterator.estimatedRowCount > 1}">
    <f:selectItems value="#{bindings.managerId.items}"/>
    When page refreshes component executes his binding method. But in some cases, actually when I press the commandMenuItem leading to the same page where I am it seems that it doesn't get invoked.. how can I manage the invocation of backing bean's methods? I need it invoked every time any request is made.. How to do that?

    Mario,
    this method is executed when the component re-draws. So anything other than a PPR request makes this binding method being called.
    If PPR is used with your commandMenuItem, them make sure the PPR trigger is set to refresh the component.
    I don't know what code it is that you need to execute each time, but maybe putting this on a action listener is a better idea
    Frank

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

  • ValueChangeListener not invoking backing bean method

    Hi Everybody
    I am using a valueChangeListener attribute with <h:selectOneListbox>. As i am using onChange, the form is getting submitted but the associated backing bean method is not getting invoked.
    My JSP code:
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <html>
       <head>
          <title>Song Detail</title>
       </head>
       <body>
          <f:view>   
               <h:form id="songForm">
                       <H4>Select a song to view detail.</H4>
                </Br>
                       <h:selectOneListbox id="songList" value="#{songBean.selectedSong}"
    valueChangeListener="#{songBean.songInformation}" immediate="true" onchange="submit();">
                              <f:selectItems value="#{songBean.songList}"/>
                     </h:selectOneListbox>
                <p>
                 <h:outputText id="result" value="#{songBean.songDetail}"/>
             </p>   
         </h:form>                  
       </f:view>
      </body>
    </html> My Backing bean method:
    public void songInformation(ValueChangeEvent vce) throws AbortProcessingException
              System.out.println("Method invoked");
           } This songInformation() method is not getting invoked.
    Please help.

    I never say to put every bean in session scope.
    I recommend that the following beans are in session scope:
    (1) the value property of h:dataTable
    (2) the value property of f:selectItems
    (3) the rendered property
    They are evaluated before Update Model Values phase.

  • ADF Faces Declarative Component onLoad event call Backing Bean Method

    Hello.
    We are trying to implement a declarative component, that will be used as Flex Fields for our application, ie, the components will be created dynamically through a database configuration, and who is responsible for organizing and creating the components, is the declarative components, and its own backing bean.
    The declarative component, will receive a List of custom components, and with this list it is possible to create the components dynamically. We want the components to be created as soon as the page is loaded. The developer could place this declarative component in any region of his page, and even in another tab if he wishes. The problem is, that we cannot register a load event in the declarative component, since it doesn't have a document Object, to call the declarative components backing bean method that is responsible for creating components.
    How could we simulate the onLoad (of the declarative components) so that the backing bean method (responsible for creating component, and putting it in the view tree) could be called ?
    I've tried with a RENDER_RESPONSE phaseListener, but the beforePhase has no objects in the tree, and the afterPhase has already rendered to the client.
    Any ideas on how to achieve this ?
    Thanks a lot.
    Regards,
    John

    Hi Frank, thanks for the response.
    I'm curious about the dynamic declarative component. Any place I could check it out ?
    Back to my scenario. I'll try to be more clear to what we need!
    We have to have dynamic creation of components, based on a database configuration. This will allow our customers to have custom flex fields, without the need of us developing custom pages for each customer.
    One solution we are trying out, is the declarative component. Why ? Because the developer (when developing the page), knows that this specific page, is possible of customization by the client (custom flex fields). With this, the developer would choose where on his page the custom flex fields will be placed. Note that at this point (design time), no component (input, buttrons, etc) is created. The idea of the declarative component, is just so the Developer knows where he wants the custom fields placed in his page (a tab, below the form fields, in a another panel group, and so on). The declarative component, has only a container, PanelFormLayout, and no other component.
    What we want, is a way of calling our managed bean (the managed bean of the declarative component, that now I did configure it in the adfc-config.xml file , thanks for the tip) method, that's responsible for creating the custom components. The declarative component, receives a list of all the custom fields that needs to be created, at design time, through an attribute. The developer is responsible for setting this list when he drags the declarative component on his page.
    Now that I've put the declarative components managed bean in the adfc-config.xml file, the @PostConstruct is called correctly, but I still have a problem. At this moment (postContstruct call), my component PanelFormLayout (that is binded to the managed bean), is null. So I cannot add any component to the PanelFormLayout.
    Am I way out of line here Frank ?
    Really appreciate your comments.
    Thanks a lot.
    John

  • a4j:commandButton Back end bean method is not invoked on click event.

    I am using below code. It seems back end bean method is not called when I click commandbutton. I think it has some thing to with rendering.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:ui="http://java.sun.com/jsf/facelets"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:a4j="http://richfaces.org/a4j"
         xmlns:rich="http://richfaces.org/rich"
         xmlns:cdm="http://mportal.com/cdm">
    <ui:composition>
         <rich:panel>
              <a4j:form id="RefreshPropertiesInstanceForm">
                   <table id="RefreshPropertiesTable" width="100%" border="0">
                        <tr>
                             <td width="35%" align="right">
                             <div class="fieldLabel">Property File Name :<span
                                  class="requiredField">*</span></div>
                             </td>
                             <td style="margin-top: 15px; padding-left: 15px" nowrap="nowrap"
                                  align="left"><rich:comboBox id="combo"
                                  value="#{testPropertyRefreshHelper.selectedPropertyFile}"
                                  enableManualInput="false">
                                  <f:selectItems value="#{testPropertyRefreshDetails.propertyFileNameList}" />
                                  <a4j:support event="onchange"
                                       reRender="RefreshPropertiesInstanceForm" BypassUpdates="false"
                                       ajaxSingle="true" action="#{testPropertyRefreshHelper.getPropertyFileContentFromRemoteServer}" />
                             </rich:comboBox></td>
                        </tr>
                        <tr>
                             <td style="margin-top: 10px; padding-left: 100px" align="left"
                                  colspan="3"><h:inputTextarea id="firstTextArea" value="#{testPropertyRefreshHelper.propertyFileContent}"
                                  rows="21" cols="150"
                                  style="overflow-x: auto; overflow-y: scroll"
                                  rendered="#{testPropertyRefreshHelper.selectedPropertyFile != 'Choose from below'}"
                                  disabled="#{testPropertyRefreshHelper.selectedPropertyFile == 'Choose from below'}">
                             </h:inputTextarea></td>
                        </tr>
                        <tr>
                             <td style="margin-top: 10px; padding-left: 400px" align="left"
                                  colspan="2">
                             <a4j:commandButton id='refreshPropertyButton' value="refresh"
                                  image="#{imageManager.imageMap['REFRESH_BUTTON']}"
                                  rendered="#{testPropertyRefreshHelper.selectedPropertyFile != 'Choose from below'}"
                                  action="#{testPropertyRefreshHelper.updatePropertyFileContentInRemoteServer}"
                                  reRender="RefreshPropertiesInstanceForm" >     
                             </a4j:commandButton>
                             </td>
                        </tr>
                   </table>
              </a4j:form>
         </rich:panel>
    </ui:composition>
    </html>
    Every thing works perfectly. But when I click command button "#{testPropertyRefreshHelper.updatePropertyFileContentInRemoteServer}" backing bean method is not invoked. Other componenets are working properly.

    try what the linked article says: make your bean session scoped.
    NOTE: when working with Ajax I tend to make the backing bean session scoped to have less issues with partial updates and such. If you use JSF 2.0 you could make it view scoped to get the same result.

  • Calling a backend bean method from another class

    Hi,
    I'm new in JSF & in this forum so maybe this question is already aswer.
    My problem is that I made a jsf component to deal with a tree menu. The resources in the leaf nodes of the menu are stored in a action calling pattern (i.e.: #{myBean.myMethod}) & I'm looking for a way to bind & execute the call from the class of the component that treats the events.
    I suppose that I need to get the current instance of the context, get the bean location, instance it & invoke the method, but I don�t know how.
    I have another more question, may this resource invocation have any kind of undesirable side effect, I meen, it's me & not the faces context who is making the call so I'm not sure if that the best way to solve the problem.
    Thanks in advance.

    If I understand what you're saying correctly... you have a component which enables a user to select an action (leaf nodes in the menu). You are processing this selection in your component and now have a EL expression that looks like #{myBean.myMethod}. You now need to know how to use that expression from Java code to invoke it. Is that correct?
    If so:
    FacesContext ctx = FacesContext.getCurrentInstance();
    MethodBinding mb = ctx.getApplication().createMethodBinding("#{myBean.myMethod}", new Class[] {});
    mb.invoke(ctx, null);
    This should do what you want. If you need to pass arguments to the method, you can do that as well... you need to pass in the types via the Class[], and the objects via an Object[] instead of null.
    Note also that the API's for EL change for JSF 1.2 to the standard EL API's, however, the older API's (above) are still supported.
    Ken Paulsen
    https://jsftemplating.dev.java.net

Maybe you are looking for

  • How Does The BEA WebLogic Face This Competition?

    Websphere application server 4.0 is claiming that it will be the ultimate application server and it soon 'll become the no.1 in the market because WebSphere Application Server, Version 4 Leverage your e-business with the foundation of the most rapidl

  • Apple TV - No Sound Output

    I have an apple tv set up with my macbook and it the past it has worked with no complications until tonight. When I try to link it , it either kicks my macbook off Apple tv altogether or it plays video but doesn't play the sound OR it selects the App

  • Documents in the Cloud - Need an easy answer

    I have OS X Mountain Lion on a 27 inch iMac and 13 inch MacBook Pro, iPhone 4 and an iPad 2. I am trying to use iCloud to sync documents such as Pages Keynote and Numbers between them seamlessly. I have documents in the cloud turned on on all of my d

  • H.264 vs Spark - Encoding Test Application

       Try it here: http://www.flaxbin.com/2011/11/flash-player-11-h-264-encoder/

  • No video on our end

    Just tried skype on xbox one. We could see them but they could not see us. The lower right hand mini screen is completely green. When I go into kinect settings, it works in there. Thoughts?