ArrayList populates twice

Hi Gurus,
I have a form that has a selectOneMenu. The drop down displays the correct data but it list it twice. I did see some other people on-line had this problem but I did not see a solution that would work for me. Below is my backing bean and jsf page. It is pretty simple code. I am just missing something......... :( thanks
public List getProgList() {
System.out.println("Making prog List");
try {
DADFacadeLocal srLocal =
(DADFacadeLocal)new InitialContext().lookup("java:comp/env/ejb/DADFacade");
FacesContext ctx = FacesContext.getCurrentInstance();
List programList = srLocal.queryProgramCodesFindAll();
Iterator it = programList.iterator();
while(it.hasNext()){
ProgramCodes programCodes = (ProgramCodes)it.next();
SelectItem sItem = new SelectItem();
String progCode = programCodes.getProgramCode();
String progName = programCodes.getProgramCode() + " -- " + programCodes.getDescription();
sItem.setLabel(progName);
sItem.setValue(progCode);
progList.add(sItem);
} catch (NamingException e) {
// TODO
e.printStackTrace();
return progList;
<body><h:form binding="#{backing_req_request.form1}" id="form1">
<h:selectOneMenu binding="#{backing_req_request.selectOneMenu1}"
id="selectOneMenu1">
<f:selectItems value="#{backing_req_request.progList}"
binding="#{backing_req_request.selectItems1}"
id="selectItems1"/>
</h:selectOneMenu>
</h:form></body>

I get around this by filling my drop down ArrayLists is separate methods that always start with a new ArrayList()
Here is a simple sample of a canned list and associated code from JSP file.
SessionBean1 has
ArrayList noYesList = yesNoList();
    public ArrayList noYesList()
        ArrayList alist = new ArrayList();
        alist.add( new SelectItem( "0", "No"));
        alist.add( new SelectItem( "1", "Yes"));
        return alist;
    }    <h:selectOneMenu binding="#{SessionBean1.noYesDD}"  id="noYesDD"
       style="height: 22px; left: 220px; position: absolute; width: 60px" value="#{SessionBean1.selectedNoYes}">
     <f:selectItems binding="#{SessionBean1.noYesData}" id="noYesDD" value="#{SessionBean1.noYesList}"/>
   </h:selectOneMenu>

Similar Messages

  • Populate 1 table based on another table

    I have a "VISITOR_TRACKER" application with the following 2 tables:
    VISITORS (table)
    VISITOR_ID (pk)
    F_NAME
    L_NAME
    VISITOR_DETAILS (table)
    V_DETAILS_ID (pk)
    V_TIME_IN
    V_DESTINATION
    I want to do the following:
    1. The visitor types in his/her last name in a search box.
    2. Everyone with that last name shows up in either a report or a drop-down select list. The visitor selects his/her name.
    3. A form "displays only" the name selected and has 2 text fields for the customer to enter their DESTINATION and TIME_IN and presses the submit button.
    How do I set this up? The problem I'm encountering is that if I create a form w/report off of the VISITORS table, I'm unable to populate the DESTINATION and TIME-IN because the F_NAME and L_NAME from the VISITORS table is already popluted - it is trying to populate twice.
    I tried basing the form w/report off of the VISITOR_DETAILS table but my report shows only the names that have any records in VISITOR_DETAILS. Also, the form shows the details of the VISITOR_DETAILS record that was selected.
    My report query looks like this:
    select "VISITOR_DETAILS"."V_DETAILS_ID" as "V_DETAILS_ID",
    "VISITOR_DETAILS"."VISITOR_ID_LU" as "VISITOR_ID_LU",
    "VISITORS"."F_NAME" || ' ' || "VISITORS"."L_NAME" as "NAME"
    from "VISITOR_DETAILS" "VISITOR_DETAILS",
    "VISITORS" "VISITORS"
    where "VISITOR_ID_LU" = "VISITOR_ID"
    I prefer to have a drop-down select list instead of a report if possible.
    Please help! I have been working HOURS on this?

    if you only want a duplicat of the structure and don't worry about constraints, indexes, triggers etc you could use something like this
    create table emp_dup as
    select * from emp
    where 1=0;Another more flexible way is to use the package DBMS_METADATA
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_metada.htm#ARPLS026

  • Sorting ArrayList multiple times on Multiple Criteria

    I have an arraylist that is sorted with Collection.sort() calling the ComparTo() included below. CompareTo sorts the file on totalLaps, totalSeconds, and etc.. The question is how do I change the sort criteria later in my process so that the arraylist is sorted on sequence number (the first field and a long number)? The only way I can currently think of doing it is to copy the array and create a separate class file like RaceDetail2 that implements a different CompareTo. To me that seems ridiculous!
    I've self tought myself Java using the online tutorials and a few books so sometimes I find I have some basic gaps in knowledge about the language. What am I missing? Seems like it should be simple.
    private ArrayList detailsArrayList = new ArrayList( );
    // Sort arraylist using compareTo method in RaceDetail file
    Collections.sort(detailsArrayList);
    public class RaceDetail implements Comparable, Cloneable {
         public RaceDetail( long seqNum, String boatNumText, int lapNum, String penalty, String question, long seconds, int totalLaps, long totalSecs, long lastSeqNum, long avg, long interval )
    public int compareTo( Object o )
         RaceDetail rd = (RaceDetail) o;
         int lastCmp = (totalLaps < rd.totalLaps ? -1: (totalLaps == rd.totalLaps ? 0: 1));
         int lastCmpA = boatNumText.compareTo(rd.boatNumText);
         int lastCmpB = (lapNum < rd.lapNum ? -1: (lapNum == rd.lapNum ? 0 : 1 ));
         int lastCmpC = (totalSecs < rd.totalSecs ? -1 : (totalSecs == rd.totalSecs ? 0 : 1 ));
         int lastCmpD = (seqNum < rd.seqNum ? -1 : (seqNum == rd.seqNum ? 0 : 1 ));
         int lastCmpE = (seconds < rd.seconds ? -1 : (seconds == rd.seconds ? 0 : 1 ));
         int lastCmpF = (lastSeqNum < rd.lastSeqNum ? -1 : (lastSeqNum == rd.lastSeqNum ? 0 : 1 ));
         // TotalLaps - Descending, TotalSeconds - ascending, lastSeqNum - ascending
         // Boat - Ascending, Second - ascending, seqNum - ascending
         return (lastCmp !=0 ? -lastCmp :
              (lastCmpC !=0 ? lastCmpC :
                   (lastCmpF !=0 ? lastCmpF :
                        (lastCmpA !=0 ? lastCmpA :
                             (lastCmpE !=0 ? lastCmpE :
                                  lastCmpD)))));
    }

    Thanks talden, adding the comparator below in my main program flow worked and now the arraylist sorts correctly. A couple of additional questions. I tried to place this in my RaceDetail class file and received a compile error so placed it in the main program flow and it worked fine. For organization, I would like to place all my sort routines together. Is there some trick to calling this method if I place it in my RaceDetail? Am I even allowed to do that?
    dhall - just to give you a laugh, this arraylist populates a JTable, uses a TableModel, and the TableSorter from the tutorial. Sorting works great in the JTable. Problem is I have to sort the arraylist a couple of times to calculate some of the fields such as lap times and total laps. I went through the TableSorter 5 or 6 times and never could figure out how to adapt it for what I wanted to do. So here I am using an example in my program and can't interpret it.
    Collections.sort( detailsArrayListLeft, SORT_BY_SEQUENCE );
    static final Comparator SORT_BY_SEQUENCE = new Comparator() {
    public int compare ( Object o1, Object o2 )
         RaceDetail rd1 = (RaceDetail) o1;
         RaceDetail rd2 = (RaceDetail) o2;
         return (rd1.seqNum() < rd2.seqNum() ? -1 : (rd1.seqNum() == rd2.seqNum() ? 0 : 1 ));

  • Populate dropDown or listBox with Directory Listing

    I need to populate a dropDown or listBox component with a directory listing from the Server.
    For example:
    \Import\XML_Files\*.xml
    Can someone point me in the right direction?
    Thanks

    Here is a hint
    File directory = new File(path);
    String[] files = directory.list();
    List fileList = new ArrayList();
    Populate the "fileList" with "files" (may need to create an object to get the file name)
    Ex
    class MyFileObject(){
    private String fileName;
    public getFileName(){
    return fileName;
    Create a object list data provider with the File List above. Now bind this data provider to the drop down list
    See my blog on how to use the Object List Data Provider
    http://blogs.sun.com/roller/page/winston?entry=objectlistdp_sample_project
    - Winston
    http://blogs.sun.com/roller/page/winston?catname=Creator

  • Workshop 8.1: Page Flow Action and jsp:include

    Hi everybody.
    Can i use jsp:include to "include" a page flow action ?
    I've tried it, but odd things are happening: The resource got included, but fragments of html source "around" it are been lost.
    Any ideas ?
    Thanks in advance.

    Hi Daniel
    There are 2 ways you can acheive this.
    1) Using something called Pageflowscoped form for this. This will let you use arrays for checkbox group.
    The main part will be that you need to define a member varaible of the form at the pageflow level there by the data will not be lost
    2) Using Request scoped form like you have now but need to modify the getter method to populate the "searchResult" object.
    public List getSearchResult() {
    if( null == searchResult){
    System.out.println(" Pouplate the searchResult here. ");
    searchResult= new ArrayList();
    //populate the default values.
    return this.searchResult;
    More info at:
    http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/netui/guide/conReqScopedVsPageScopedBean.html
    I have a sample with pageflowscoped bean and requestscoped bean that I can send you if you provide your email address.
    Unfortunately we cannot attach files in the newsgroup.
    Thanks
    Vimala

  • Workshop 8.1 - netui-data:repeater and netui:checkBox

    Hi everybody.
    How can i use netui-data:repeater and netui:checkBox to build a group of checkboxes ? I need something like Struts "indexed and mapped properties" (http://struts.apache.org/struts-doc-1.1/faqs/indexedprops.html)
    I've tried something like this
    == FORM ==
    public List getSearchResult() {
       return searchResult;
    public void setSearchResult(List searchResult) {
       this.searchResult = searchResult;
    }== JSP ==
    <<netui-data:repeater dataSource="{actionForm.searchResult}">>
    <<tr bgcolor="#ffffff" class="text8b">>
    <<td>><<netui:checkBox dataSource="{container.item.selected}" />><</td>><</tr>>
    <</netui-data:repeater>>
    I can see the values inside this page but when i submit this form, my list is empty (null).
    What is the right way of do it ?
    Thanks in advance.

    Hi Daniel
    There are 2 ways you can acheive this.
    1) Using something called Pageflowscoped form for this. This will let you use arrays for checkbox group.
    The main part will be that you need to define a member varaible of the form at the pageflow level there by the data will not be lost
    2) Using Request scoped form like you have now but need to modify the getter method to populate the "searchResult" object.
    public List getSearchResult() {
    if( null == searchResult){
    System.out.println(" Pouplate the searchResult here. ");
    searchResult= new ArrayList();
    //populate the default values.
    return this.searchResult;
    More info at:
    http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/netui/guide/conReqScopedVsPageScopedBean.html
    I have a sample with pageflowscoped bean and requestscoped bean that I can send you if you provide your email address.
    Unfortunately we cannot attach files in the newsgroup.
    Thanks
    Vimala

  • Why is my test not working?

    Hello All,
    I have a Arraylist whuch when printed out looks like this:
    [id, firstname, middlename, , LlastName]
    and I have a if statement like so
    if (Arraylist.contains(" ")){
    System.out.println("it works");
    }why does this not print out the line I want when there is a blank space in my Arraylist?
    Thanks
    Boggis

    The method you are invoking checks if the Object specified as parameter is one of the elements inside the ArrayList.
    e.g.:
    String s1 = "hello world";
    String s2 = "foo.com";
    String s3 = "testing";
    String s4 = "do not add this string to an ArrayList!";
    ArrayList list = new ArrayList();
    list.add(s1);
    list.add(s2);
    list.add(s3);
    if(list.contains(s1)) {
       System.out.println("list contains s1");
    else {
       System.out.println("list doesn't contain s1");
    if(list.contains(s4)) {
       System.out.println("list contains s4");
    else {
       System.out.println("list doesn't contain s4");
    }this example code will result the following outputs:
    list contains s1
    list doesn't contain s4The method is not used to check if an element of the ArrayList contains a special String!
    To check this you might use some code like this:
    ArrayList list = new ArrayList();
    // populate the ArrayList ...
    for(int i=0; i<list.size(); i++) {
       String test = list.get(i).toString(); // list.get(i) will return an Object
       if(test.indexOf(" ") == -1) {
          System.out.println("list element at index " + i + " doesn't contain \" \"");
       else {
          System.out.println("list element at index " + i + " contains \" \"");
    }

  • Populate an arraylist....

    Hi guys,
    i'm a new java user and i have a big question for you.
    I'm developing a jsf application with eclipse and i have a problem.
    I have to import a txt file with this format
    string string string string
    string double double double
    string double double double
    string double double double
    etc....
    The file is composed by a first row that has 4 columns of string type
    and other rows of 4 columns with first column string and the others double.
    I have to define 2 object, a first headline object that is an array of string, for storing the first row, and a second object that is composed by a string field and by an array of double.
    Headline string[]=new string[4];
                public class row{
                     String geneid=null;
                     values double[]=null;
                public void row(String idGene,double[3] x ) {
                    this.geneid=idPr;
                    this.values=x;
                  }This code is correct?
    For storing my file i need an headline array of string and an arraylist of row objects.
    How can populate them with the txt file?
    I've loaded the file with
    BufferedReader br = new BufferedReader(new InputStreamReader(myFile.getInputStream())); Can you help me with some code?I'm not expert....

    This is not a JSF question. Please put your question on New to Java Programming or in Java Programming forum

  • How to populate arrayList values in a Excel cell using java

    Hi ,
    Iam trying to create Excel sheet using java with Apache-POI api's.I need to display values from an arrayList into Excel cell as drop down.kindly suggest me any idea or share any code if u have any.
    Thanks in advance
    Regards
    Rajesh

    I suggest you use google to find examples.

  • Thumbnails populate slowly, and file import twice (two questions)

    Lately, I've been noticing that thumbnails take longer than usual to populate for existing images in the Grid View.  I'm using LR 5.6, Windows 7-64 Professional.  Plenty of RAM and an SSD where the catalog and .lrdata reside.  Any thoughts on how I might improve matters?
    Also, I notice when I import images from my camera that already imported images sometimes get imported again.  I've checked the box "don't import suspected duplicates" and I'm selecting "New Photos."  Again, any input would be appreciated.
    Thank you,
    Robert 

    Lately, I've been noticing that thumbnails take longer than usual to populate for existing images in the Grid View.  I'm using LR 5.6, Windows 7-64 Professional.  Plenty of RAM and an SSD where the catalog and .lrdata reside.  Any thoughts on how I might improve matters?
    Also, I notice when I import images from my camera that already imported images sometimes get imported again.  I've checked the box "don't import suspected duplicates" and I'm selecting "New Photos."  Again, any input would be appreciated.
    Thank you,
    Robert 

  • Submit twice ?

    Hello all.
    I'm writing a jsf app that takes an input form, validates it, and then
    forwards the user to a confirmation page.
    Pretty straightforward, very similar to jsf tutorials.
    However, once I added selectOneMenu items, I now find
    myself having to submit the form twice before getting the
    confirmation page.
    The selectOneMenu items do have valueChangeListener
    routines in the backing bean, because if I did not include
    those, it would not return the value selected in the drop-down
    boxes.
    The form is submitted by a commandButton, which calls a
    validate() routine in the backing bean, which returns null if
    not validated or 'success' if validated, which should then
    forward the browser to the confirm page.
    I put System.out.println() messages in the valueChangeListener
    as well as the validate() routine, and the first submit shows the
    messages in valueChangeListener, the second shows the validate()
    routine messages.
    Maybe I'm missing something in the lifecycle order that may
    cause this, but I have not been able to make it work right.
    Has anyone come across this behavior in jsf ?
    If anyone is interested, I can email a jar with the source,
    xml (faces-config.xml, web.xml), and jsp files.
    There seems no way to attach it in the forums.
    I can, however, post snippets of how I code the drop-downs:
    jsp file:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
       <td align="left">  
          <h:selectOneMenu value="#{data.state}"
                  valueChangeListener="#{data.stateSelected}">
             <f:selectItems value="#{data.statelist}"/>
          </h:selectOneMenu>
       </td>
    java source:
    (drop-downs populate fine......)
       public Collection getStatelist(){
          //System.out.println(getLogtime() + "DataBean: getStates()");
          if (sdata==null)
             try{
                populateStates();
             } catch(SQLException sqlEx) {
                logger.log(Level.SEVERE, "loginAction", sqlEx);
             } catch(NamingException nameEx) {
                logger.log(Level.SEVERE, "loginAction", nameEx);
             } catch(Exception Ex) {
                System.out.println(getLogtime() + "DataBean: getStates() Exception!");
                //System.out.println("  nbr of state records: [" + sdata.size() + "]");
                System.out.println("   msg: [" + Ex.getMessage() + "]");
                //return sdata;
          //System.out.println(getLogtime() + "DataBean: nbr of State records: [" + sdata.size() + "]");
          return sdata;
       public void populateStates()
          throws SQLException, NamingException
          //System.out.println("DataBean: populateStates()...");
          //ctx = new InitialContext();
          ctx = new InitialContext(System.getProperties());
          if(ctx==null){
               throw new NamingException("DataBean: No initial context");
          ds = (DataSource)ctx.lookup("java:/comp/env/jdbc/testdataDS");
          if(ds==null){
             System.out.println("DataBean: no data source!!");
             throw new NamingException("No data source");
          //System.out.println("DataBean: getConnection...");
          try {
             conn = ds.getConnection();
             if(conn==null) {
                System.out.println("DataBean: no connection!!");
                throw new SQLException("DataBean: No database connection");
             } else {
                PreparedStatement dataQuery = conn.prepareStatement(
                   "SELECT state_code, state_name FROM state ORDER BY state_code");
                ResultSet result = dataQuery.executeQuery();
                sdata = new ArrayList();
                sdata.add(new SelectItem(" ","Please select one"));
                if(!result.next()){
                   return;
                } else {
                   sdata.add(new SelectItem(result.getString("state_code")
                                           ,result.getString("state_name")));
                   while(result.next()){
                      sdata.add(new SelectItem(result.getString("state_code")
                                              ,result.getString("state_name")));
          } catch(SQLException se){
             System.out.println("DataBean: populateStates() - connection/statement/execute : ");
             System.out.println("   message: [" + se.getMessage() + "]");
             //se.printStackTrace();
             // look at the warnings issued it should help you resolve the problem
             SQLWarning warning = null;
             try {
                // Get SQL warnings issued
               //warning = conget.getWarnings();
               warning = (SQLWarning)se.getNextException();
               if (warning == null) {
                  System.out.println("DataBean: populateStates()could not get sql warnings");
               } else {
                  //while (warning != null) {
                     System.out.println("DataBean populateStates() - Warning: " + warning);
                     //warning = warning.getNextWarning();
                  //   warning = (SQLWarning)se.getNextException();
             } catch (Exception we) {
                System.out.println("DataBean populateStates() - SQLException !!");
                System.out.println("   msg: [" + we.getMessage() + "]");
             sdata = new ArrayList();
          } catch (Exception e) {
             System.out.println("DataBean: populateStates() lookup exception:");
             System.out.println("  msg: [" + e.getMessage() + "]");
             e.printStackTrace();
             sdata = new ArrayList();
          } finally {
             conn.close();
    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>
       <application>
         <locale-config>
              <default-locale>en</default-locale>
              <supported-locale>en</supported-locale>
              <supported-locale>en_US</supported-locale>
              <!-- supported-locale>de</supported-locale -->
         </locale-config>
         <!-- message-bundle>
              de.laliluna.tutorial.messageresource.MessageResources
         </message-bundle -->
       </application>
       <!-- managed beans of the simple hello world app -->
       <managed-bean>
          <managed-bean-name>data</managed-bean-name>
          <managed-bean-class>edu.msu.hit.data.DataBean</managed-bean-class>
          <managed-bean-scope>session</managed-bean-scope>
       </managed-bean>
       <!-- Navigation rules -->
       <navigation-rule>
          <description>Test select one page</description>
          <from-view-id>/testSelectOnePage.jsp</from-view-id>
          <!-- navigation-case>
             <from-outcome>ticketsfailure</from-outcome>
             <to-view-id>/ticketsonline.jsp</to-view-id>
          </navigation-case -->
          <navigation-case>
             <from-outcome>success</from-outcome>
             <to-view-id>/testSelectOneConfirm.jsp</to-view-id>
          </navigation-case>
       </navigation-rule>
    </faces-config>
    web.xml:
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
       <display-name>MyFaces Demo</display-name>
       <description>a Myfaces demo page</description>
        <!-- Listener, that does all the startup work (configuration, init). -->
        <!-- listener>
           <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
        </listener -->
        <!-- Faces Servlet -->
        <servlet>
          <servlet-name>Faces Servlet</servlet-name>
          <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
        </servlet>
        <!-- Faces Servlet Mapping -->
        <servlet-mapping>
          <servlet-name>Faces Servlet</servlet-name>
          <url-pattern>*.faces</url-pattern>
        </servlet-mapping>
        <resource-ref>
          <description>Sybase Datasource resource</description>
          <res-ref-name>jdbc/testdataDS</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
        </resource-ref>
        <welcome-file-list>
          <welcome-file>index.html</welcome-file>
          <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
        <context-param>
           <param-name>com.sun.faces.validateXml</param-name>
           <param-value>false</param-value>
           <description>
              Set this flag to true if you want the JavaServer Faces
              Reference Implementation to validate the XML in your
              faces-config.xml resources against the DTD. Default
              value is false.
           </description>
        </context-param>
        <context-param>
            <param-name>log4jConfigLocation</param-name>
            <param-value>/WEB-INF/log4j.properties</param-value>
        </context-param>
        <!-- context-param>
            <param-name>javax.faces.CONFIG_FILES</param-name>
            <param-value>
                /WEB-INF/faces-config.xml
            </param-value>
            <description>
                Comma separated list of URIs of (additional) faces config files.
                (e.g. /WEB-INF/my-config.xml)
                See JSF 1.0 PRD2, 10.3.2
            </description>
        </context-param -->
        <context-param>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>client</param-value>
            <description>
                State saving method: "client" or "server" (= default)
                See JSF Specification 2.5.2
            </description>
        </context-param>
        <context-param>
            <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
            <param-value>true</param-value>
            <description>
                This parameter tells MyFaces if javascript code should be allowed in the
                rendered HTML output.
                If javascript is allowed, command_link anchors will have javascript code
                that submits the corresponding form.
                If javascript is not allowed, the state saving info and nested parameters
                will be added as url parameters.
                Default: "true"
            </description>
        </context-param>
        <context-param>
            <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
            <param-value>true</param-value>
            <description>
                If true, rendered HTML code will be formatted, so that it is "human readable".
                i.e. additional line separators and whitespace will be written, that do not
                influence the HTML code.
                Default: "true"
            </description>
        </context-param>
        <context-param>
            <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
            <param-value>false</param-value>
        </context-param>
        <context-param>
            <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
            <param-value>true</param-value>
            <description>
                If true, a javascript function will be rendered that is able to restore the
                former vertical scroll on every request. Convenient feature if you have pages
                with long lists and you do not want the browser page to always jump to the top
                if you trigger a link or button action that stays on the same page.
                Default: "false"
            </description>
        </context-param>
        <!-- the following context-params are for jsf 1.1 -->
        <!-- tjc 2007-02-07 -->
        <context-param>
            <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
            <param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value>
        </context-param>
        <context-param>
            <param-name>org.apache.myfaces.redirectTracker.POLICY</param-name>
            <param-value>org.apache.myfaces.redirectTracker.NoopRedirectTrackPolicy</param-value>
        </context-param>
        <context-param>
            <param-name>org.apache.myfaces.redirectTracker.MAX_REDIRECTS</param-name>
            <param-value>20</param-value>
        </context-param>
        <context-param>
            <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
            <param-value>false</param-value>
        </context-param>
        <context-param>
            <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
            <param-value>false</param-value>
        </context-param>
    </web-app>I'm running jsf 1.1, tomcat v5.5.20, apache 2.059, JK 1.2.18
    Thanks to anyone for insight.

    Hello. Me again.
    I did not post the JSP file that was using the above code, so I
    decided to post it, and mention that if I use:
    onchange="submit();"within the <h:selectOneMenu> tag, the form does not need to be
    submitted twice, but takes the values and validates them.
    On the other hand, if your form is long enough, and you have to scroll
    down to change the drop-down box, the form is submitted, and
    so it takes you to the top of the page again.
    I guess that I could design the page so that the entire form fits
    within the browser without scrolling, but that would depend on
    how big the user makes their browser window.
    Anyway, here is the JSP:
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <f:view>
    <%
    * MOCF ball tickets order form.
    %>     
    <jsp:include page="./headerform.jsp">
       <jsp:param name="pagetitle" value="MOCF Ball Tickets Purchase Page" />     
       <jsp:param name="page" value="tickets" />     
    </jsp:include>
    <center>
    <h:form>
    <table border="2" cellspacing=1 cellpadding=2>
    <tr>
       <td align=center>
       <h:outputText value="#{mocfBall.mocfyear}"/>
        <h:outputText value="#{mocfBall.mocftitle}"/><br>
         <b><i>
         <h:outputText value="#{mocfBall.mocfslogan}"/>
         </i></b><br>
         <h:outputText value="#{mocfBall.mocflocation}"/><br>
         <h:outputText value="#{mocfBall.mocfcity}"/><br>
         <h:outputText value="#{mocfBall.mocfdate}"/><br>
       </td>
    </tr>
    </table>
    <table border="0" cellspacing=1 cellpadding=2 width="90%">
    <tr>
       <td align=center>
          MOCF Ball Tickets PURCHASE FORM
       </td>
    </tr>
    <tr>
       <td align=center>
          Date/Time: 
            <h:outputText value="#{mocfBall.currentdatetime}"/>
       </td>
    </tr>
    <!-- tr>
       <td align=center>
            <a href="./ticketsprint.jsp">
               LINK to PRINTABLE FORM<br>
               (You can click here, then print the page,<br>
               and send it in the mail with your check.)
            </a>
         </td>
    </tr -->
    <tr>
       <td align=center>
          <font size="2" face="arial">
                 You may print this form and fill in the fields by hand,
                 <br>or<br>
                 fill in the fields now by typing, then print the form with the
                 PRINT button in the browser menu above, or the "Print Page"
                 button below.
                 <br><br>
                 For questions, please contact:<br>
                 <h:outputText value="#{mocfBall.mocfcontactname}"/>
                  at 
                 <h:outputText value="#{mocfBall.mocfcontactphone}"/>
                  or by email at 
                 <h:outputText value="#{mocfBall.mocfcontactemail}"/>
                 <br><br>
                 To use the postal service instead of online submission,
                 please mail this form, with your check, to:<br>
                 <h:outputText value="#{mocfBall.mocfsnailtitle}"/><br>
                 <h:outputText value="#{mocfBall.mocfsnailaddr1}"/><br>
                 <h:outputText value="#{mocfBall.mocfsnailaddr2}"/><br>
                 <h:outputText value="#{mocfBall.mocfsnailaddr3}"/><br>
              </font>
           </td>
    </tr>
    <tr>
       <td align=right>
          <a href=<h:outputText value="#{mocfBall.mocfhome}"/>>MOCF Ball Home</a>
       </td>
    </tr>
    </table>
    <table width="90%" border="1" cellpadding="2" cellspacing="0">
      <tr>
        <td width="100%" valign="top" colspan="2" align="center">
            (* = field required)
        </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *Salutation:
         </td>
         <td align="left" valign="top">
            <h:selectOneMenu id="formSalutations"
                     valueChangeListener="#{ticketsformBean.mocfsalutationSelected}"
                     value="${ticketsformBean.mocfsalutation}">
                <f:selectItems value="#{ticketsformBean.allsalutations}"/>
            </h:selectOneMenu>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.salutationerror}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *First name:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocffirstname}" size="40"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.firstnameerror}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *Last name:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocflastname}" size="40"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.lastnameerror}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *Address1:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocfaddress1}" size="40"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.address1error}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *Address2:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocfaddress2}" size="40"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.address2error}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *City:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocfcity}" size="30"/>
            <font size="-2px" color="red">
            <br>
            <h:outputText value="#{ticketsformBean.cityerror}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *State:
         </td>
         <td align="left" valign="top">
            <h:selectOneMenu id="states"
                     valueChangeListener="#{ticketsformBean.mocfstateSelected}"
                     value="${ticketsformBean.mocfstate}">
                <f:selectItems value="#{ticketsformBean.allstates}"/>
            </h:selectOneMenu>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.stateerror}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *Zip:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocfzip}" size="10"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.ziperror}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *Phone:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocfphone}" size="10"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.phoneerror}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            Fax:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocffax}" size="10"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.faxerror}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *Email:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocfemail}" size="60"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.emailerror}"/>
            </font>
         </td>
      </tr>
    </table>
    <table width="90%" border="1" cellpadding="2" cellspacing="0">
      <tr>
         <td align="right" valign="top">
            *Number of tickets to reserve:
         </td>
         <td align="left" valign="top">
            <h:selectOneMenu id="ticketcount"
                    valueChangeListener="#{ticketsformBean.mocfnbrofticketsSelected}"
                     value="${ticketsformBean.mocfnbroftickets}">
                <f:selectItems value="#{ticketsformBean.allticketcounts}"/>
            </h:selectOneMenu>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.nbrticketserror}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *Name1:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocfname1}" size="30"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.name1error}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *Name2:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocfname2}" size="30"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.name2error}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *Name3:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocfname3}" size="30"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.name3error}"/>
            </font>
         </td>
      </tr>
      <tr>
         <td align="right" valign="top">
            *Name4:
         </td>
         <td align="left" valign="top">
            <h:inputText value="#{ticketsformBean.mocfname4}" size="30"/>
            <font class="formerror">
            <br>
            <h:outputText value="#{ticketsformBean.name4error}"/>
            </font>
         </td>
      </tr>
      <tr>
        <td align="center" valign="top" colspan="2">
          <h:commandButton value="Submit tickets order"
             action="#{ticketsformBean.validate}"/>
        </td>
      </tr>
    </table>
    </h:form>
    <br>
    <table border="0" cellspacing=1 cellpadding=2>
    <tr>
       <td align=center>
          <input type="hidden" name="form" value="print">
            <INPUT TYPE="button" name="printMe" onClick="print()" value="Print Page">
       </td>
    </tr>
    </table>
    </center>
    <h:messages />
    <jsp:include page="./footerform.jsp" />
    </f:view>

  • Database call fired twice when using actionListener in dataTable

    Hi all,
    I have a question regarding the request bean lifecylce in the current use case (using Sun JSF 1.2)
    I have a managed bean in request scope that contains an ArrayList which is used as the data provider in a dataTable on a faces page.
    The bean contains an init() method to populate the ArrayList using a database call.
    The dataTable also contains a column with a commandLink that calls a method via actionListener inside the managed bean to delete the current row.
    When I click the link the action gets called and deletes the row from the database. I also reload the data from the database and assign it to my ArrayList.
    However, the init Method is also called before the action is executed. So the database call is fired twice when hitting the link:
    - First time in the init() method of the bean
    - Second time in the actionListener method when reloading the data
    I can not remove the call from the actionListener, because the data has not deleted yet.
    Question:*
    How can I make sure the database call is fired once only? (and also making sure the ArrayList is populated appropriate)
    Maybe I am doing something wrong here? Thanks in advance for any help.
    Maik
    This is the request scope bean:
    public class UserBean implements Serializable {
        private List all;
        private Long userId = null;
        @PostConstruct
        public void init() {
            if(all == null) {
                new ArrayList();
                loadUserList();
         * Constructor
        public UserBean() {
            super();
         * @return the userId
        public Long getUserId() {
            return userId;
         * @param userId
         *            the userId to set
        public void setUserId(Long userId) {
            this.userId = userId;
         * @param all
         *            the all to set
        public void setAll(List all) {
            this.all = all;
        public List getAll() throws GeneralModelException {
            return all;
        public void loadUserList() {
            EntityManager em = Contexts.getEntityManager();
            Query q = em.createNamedQuery("user.findAll");
            all = q.getResultList();
        public void deleteAction(ActionEvent ae) {
            EntityManager em = Contexts.getEntityManager();
            Query q = em.createNamedQuery("user.byId");
            q.setParameter("id", userId);
            try {
                User user = (User) q.getSingleResult();
                if (user != null) {
                    em.remove(user);
                    loadUserList();
            } catch (NoResultException e) {
                // TODO
    }

    No, I do not call the init() method.
    Basically the init() is called before the deleteAction() so the ArrayList still contains the old value, unless a second database call is triggered after the entity has been deleted.
    Maybe I am missing something here...
    See also here (JSF 1.2 RI - Bean Instantiation and Annotation)
    [http://weblogs.java.net/blog/jhook/archive/2007/05/jsf_12_ri_backi.html]
    Here is the init() call stack trace
    Daemon Thread [http-8080-2] (Suspended (breakpoint at line 32 in UserBean))     
         UserBean.init() line: 32     
         NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]     
         NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available     
         DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available     
         Method.invoke(Object, Object...) line: not available     
         DefaultAnnotationProcessor.postConstruct(Object) line: 79     
         Tomcat6InjectionProvider.invokePostConstruct(Object) line: 118     
         ManagedBeanBuilder(BeanBuilder).invokePostConstruct(Object, InjectionProvider) line: 223     
         ManagedBeanBuilder(BeanBuilder).build(InjectionProvider, FacesContext) line: 108     
         BeanManager.createAndPush(String, BeanBuilder, ELUtils$Scope, FacesContext) line: 368     
         BeanManager.create(String, FacesContext) line: 230     
         ManagedBeanELResolver.getValue(ELContext, Object, Object) line: 88     
         FacesCompositeELResolver(CompositeELResolver).getValue(ELContext, Object, Object) line: 53     
         FacesCompositeELResolver.getValue(ELContext, Object, Object) line: 72     
         AstIdentifier.getValue(EvaluationContext) line: 61     
         AstValue.getTarget(EvaluationContext) line: 59     
         AstValue.setValue(EvaluationContext, Object) line: 129     
         ValueExpressionImpl.setValue(ELContext, Object) line: 249     
         JspValueExpression.setValue(ELContext, Object) line: 85     
         RestoreViewPhase.doPerComponentActions(FacesContext, UIComponent) line: 240     
         RestoreViewPhase.doPerComponentActions(FacesContext, UIComponent) line: 245     
         RestoreViewPhase.doPerComponentActions(FacesContext, UIComponent) line: 245     
         RestoreViewPhase.execute(FacesContext) line: 195     
         RestoreViewPhase(Phase).doPhase(FacesContext, Lifecycle, ListIterator<PhaseListener>) line: 100     
         RestoreViewPhase.doPhase(FacesContext, Lifecycle, ListIterator<PhaseListener>) line: 104     
         LifecycleImpl.execute(FacesContext) line: 118     
         FacesServlet.service(ServletRequest, ServletResponse) line: 265     

  • Check for null and empty - Arraylist

    Hello all,
    Can anyone tell me the best procedure to check for null and empty for an arraylist in a jsp using JSTL. I'm trying something like this;
    <c:if test="${!empty sampleList}">
    </c:if>
    Help is greatly appreciated.
    Thanks,
    Greeshma...

    A null check might not be you best option.  If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
    In the C# method, first check if either is an empty string, if so return an empty string.
    If not, TryParse the data, if successful, return a valid data string for EventDate.  If not, error or return empty string, whichever satsifies the requirement.

  • How to populate table in RFC

    How do I populate an abstractlist that is an input to an RFC?  I read the post by Bertram Ganz, but my generated classes look different.  I imported the RFC and the system generated the following:
    -zbapi_appraisal_create
      -zbapi_appraisal_create_input
        -appraisees (bapiappraisee)
          -bapiappraisee
            -fields...
        -output (zbapi_appraisal_create_output)
          -same as output node below
        -appraiser_id
        -rest of input parameters...
      -zbapi_appraisal_create_output
    ...etc.
    I have no problem setting the regular input parms, but how do I set the table?  I tried the following, but I get a ClassCastException on the call to setAppraisees().
    Zbapi_Appraisal_Create_Input input = new Zbapi_Appraisal_Create_Input();
    wdContext.nodeZbapi_Appraisal_Create().bind(input);
    input.setAppraisal_Model_Id(appraisalModelId);
    input.setStart_Date(startDate);
    input.setText(description);
    input.setCreation_Date(appraisalDate);
    input.setAppraiser_Id(appraiserId);
    //static values
    input.setPlan_Version("01");
    input.setAnonymous(true);
    input.setAppraiser_Type("P");
    input.setAppraiser_Plan_Version("01");
    //create appraisee
    <b>Bapiappraisee obj = new Bapiappraisee();
    obj.setPlan_Version("01");
    obj.setType("P");
    obj.setId(appraiseeId);
    obj.setName(appraiseeName);          
    List myList = input.getAppraisees();
    if (myList == null) myList = new ArrayList();
    myList.add(obj);
    input.setAppraisees((AbstractList)myList);</b>
    wdContext.currentZbapi_Appraisal_CreateElement().modelObject().execute();
    wdContext.nodeOutput().invalidate();
    Any input is greatly appreciated!!
    John<b></b>

    Please read a good manual prepared by Arun Bhat -
    <a href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f3f93ee7-0c01-0010-2593-d7c28b5377c2">Adaptive RFC Troubleshooting Guide</a>
    WDDynamicRFCException most likely comes in the following cases:
    a) JCo is not setup properly
    b) Your function module does not exist in R/3 system referred by your JCo
    c) Your function module is not RFC enabled
    d) DD_DOMA_GET is not RFC enabled
    Also make sure you have got your cardinality settings for your model node in context controller proper.
    If you have used a template approach, just check your wdDoInit method of your custom/component controller for code similar to the following:
    wdContext.nodeBAPI_Input().bind(new BAPI_Input());
    If you have the above code and the code that you have just  pasted , just comment this code and try executing your application again.
    Regards,
    Subramanian V.
    Message was edited by: Subramanian Venkateswaran

  • How to populate values in to drop down by index

    Hi in my application  i have dropdownby index with label State.In that dropdown i need to populate all the states of our country like..Tamilnadu,andhraprdesh,Gujrath,Maharastra,Delhi....,and by default it should be populated with Select State ,can u please tell me the code..
    Thanks
    Kishore

    hi,
    1.in ur context create a context value node----eg: MyStates
    2.under that value node create a value attribute--eg: values.
    3.set the cardinality of "MyStates" value node to 0:n
    4.texts property of ur dropdown by index ui element shld be bound to the value attr (values).
    5.in the wdDoInit() method of ur view that has this dropdownbyindex ui element use the follwoing code,
    String    [  ]    states_array    =        new String [  ]   {"tn", "mp", "ap", "karnataka"};
    List list_for_node_elem = new ArrayList();
       for (int i =  0; i <states_array.length; ++i)
          IPrivateMyView.IMyStatesElement elem = wdContext.createMyStatesElement();
          MyStatesElement.setValues(states_array   [i ]   );
          list_for_node_elem.add(MyStatesElement);
       wdContext.nodeMyStates().bind(list_fornode_elem);
       wdContext.nodeMyStates().setLeadSelection(1);
    Regards
    Jayapriya

Maybe you are looking for

  • My brother's emails don't appear in my Inbox

    When my brother sends me an email, it does not appear in my general Inbox or in my Gmail account sub Inbox. I can view an email from him only if he calls or texts me to tell me he is sent it and I type his name in Mac Mail's search box. And viewing h

  • Purchase order price.

    We have 1 purchase order created. In purchase order there only 1 line item without  material no. Item category is K. In the po print preview   there is no price  i can view for tax and for total value. Price is entered in the po is manual. Goods of t

  • Can I have a general daq event in visual basic while outputing in dma mode?

    Hardware: PCI-6711 Software: Visual Basic 6.0 NI-DAQ 6.9.3f3 Windows 2000 I can't get the GeneralDAQEvent_Fire subroutine to happen. I'm trying to output two synchronized waveforms on two channels at sampling rates that can be changed on the fly. To

  • Edition Based Redefinition in Oracle 11g R2

    Regarding new feature EBR in Oracle 11g r2 As we all know Editioning view is like a wrapper over the base table which allows each edition to see the table in the form it needs, all data operations will be on editioning view once the view is created.

  • HT2045 I'm trying to sync an audiobook from iTunes (iPod Shuffle) but I keep getting error message.

    I bought an iPod Shuffle today and trying to sync 1 audiobook. Keep getting error message. If I try again, it looks like it's ok but then the device won't play it... What can I do?