Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:34:04+00:00 2026-06-07T10:34:04+00:00

I get all rows in displaytag table same values i.e. It displays same values

  • 0

I get all rows in displaytag table same values i.e. It displays same values for all rows (i.e. last row values)

Below is the Action class snippet where I set the values in formbean

public class FormIdSearch extends Action {

    ResourceBundle rsBundle = ResourceBundle.getBundle("com.mindcraft.resources.ApplicationResource");
    Collection formbeanCol = new ArrayList();

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        Collection a = new ArrayList();
        FormBean formbean = (FormBean)form;
        ActionForward forward = new ActionForward();
        ActionMessages message = new ActionMessages();
        CMBConnection connection=new CMBConnection();
        HRMSUtill hrms = new HRMSUtill();
        IngUtill ing = new IngUtill();
        AppUtill au = new AppUtill();
        try{


            String polNo=formbean.getPolicyNo();
            String appN=(String)request.getAttribute("appno");
            System.out.println("Application No.1" + appN);
            String applnNo=formbean.getAppno();
            System.out.println("Application No.2" + applnNo);
            String appNo=(String)request.getParameter("appno");
            System.out.println("Application No.3" + appNo);
            HashMap<String, String> inpMap = new HashMap<String, String>();

            CMBSearchResults srchResults = null;
            CMBItem item = null;

            inpMap.put(rsBundle.getString("CM_INDEXCLASS_ADVISORSLICENSING"), rsBundle.getString("CM_INDEXCLASS_ADVISORSLICENSING"));
            //inpMap.put(rsBundle.getString("CM_INDEXCLASS_ADVISORSLICENSING"), rsBundle.getString("CM_INDEXCLASS_ADVISORSLICENSING"));
            inpMap.put(rsBundle.getString("CM_COMMON_ADVISORCODE"), "AA5555");
            inpMap.put(rsBundle.getString("CM_COLNAME_ADVISORCODE"), rsBundle.getString("CM_COLNAME_ADVISORCODE"));
            inpMap.put(rsBundle.getString("CM_COMMON_APPNUMBER"), appNo);
            inpMap.put(rsBundle.getString("CM_COLNAME_APPNUMBER"), rsBundle.getString("CM_COLNAME_APPNUMBER"));

            String winId=(String)request.getSession().getAttribute("windowsId");
            String empId = au.getEmpCodeOnWinId(winId);

            System.out.println("winId===="+winId);
            String ingBrCode="";

            if(hrmsBrCode1.equalsIgnoreCase(ingBrCode1))
            {

                ServletContext servletcontext = request.getSession().getServletContext();
                String cmbicmsrvsPath = servletcontext.getRealPath("WEB-INF/cmbicmsrvs.ini");
                System.out.println("cmbicmsrvsPath "+cmbicmsrvsPath);

                String icmsrvfilePath=servletcontext.getRealPath("WEB-INF/cmbicmsrvs.ini");
                String icmmenvfilePath=servletcontext.getRealPath("WEB-INF/cmbicmenv.ini");

                connection = new CMBConnection();
                //CMConnectionPool cmConnect = new CMConnectionPool();
                CMSearchDocuments searchDoc = new CMSearchDocuments();


                CMConnectionPool.setIcmenvfile(icmmenvfilePath);
                CMConnectionPool.setIcmsrvfile(icmsrvfilePath);
                //System.out.println("HHHEYEEEYYEYE TRUE.........3");
                connection=CMConnectionPool.getConnection();


                srchResults=searchDoc.searchForDocumentsInCM(connection, inpMap);

                Integer searchCount=srchResults.getCount();

                System.out.println("searchCount "+searchCount);
                LoggerUtil.logger.debug("searchCount "+searchCount);
                HttpSession session = request.getSession(false);
                session.setAttribute("searchCount",searchCount.toString());
                for (int i = 0; i < searchCount; i++) 
                   {
                    item = srchResults.getItem(i);

                    a=getDocumentMetaData(item,formbean);
                      String pid=item.getPidString();
                      request.setAttribute("pid", pid);
                      formbean.setPid(pid);

                   }
                request.setAttribute("formbeanCol", a);
                Object ia[] = a.toArray(); 
                int sum = 0; 
                // sum the array 
                for(int i=0; i<ia.length; i++) {
                sum += ((Integer) ia[i]).intValue(); 
                System.out.println("Sum is: " + sum); 
                } 

                if(searchCount>0){
                    //for (int i = 0; i < srchResults.getCount(); i++){
                    item = srchResults.getItem(searchCount-1);
                    //getDocumentMetaData(item);

                    String pid = item.getPidString();
                    System.out.println("pid "+pid);
                    request.setAttribute("pid", pid);

                    forward=mapping.findForward("success");

                }
                else
                {   
                    forward=mapping.findForward("failure");
                    message.add("ErrorOccurred", new ActionMessage("Invalid.SearchResult"));
                }
                System.out.println("Search Done");
                LoggerUtil.logger.debug("Search Done");
            }
            else
            {

                System.out.println("No Record Found");
                LoggerUtil.logger.debug("No Record Found");

                forward=mapping.findForward("failure");
                message.add("ErrorOccurred", new ActionMessage("Invalid.SearchResult"));
            }
            saveMessages(request, message);
        }
        catch(Exception e){
            forward=mapping.findForward("failure");
            LoggerUtil.logger.debug("Exception in FormIdSearch ",e);
            e.printStackTrace();
        }
        finally{
            try{
                if(connection!=null){
                    CMConnectionPool.freeConnection(connection);
                }
            }
            catch(Exception e)
            {
                forward=mapping.findForward("failure");
                LoggerUtil.logger.debug("Exception in FormIdSearch in finally block Closing CM Connection",e);
            }
        }
        return forward;
    }
     public Collection getDocumentMetaData(CMBItem item,FormBean formbean)
     throws CMBException, Exception 
{

     // Get document metadata attributes
        String FormID = item.getAttrValue(0);
        System.out.println(item.getAttrValue(0));
        System.out.println(item.getAttrValue(1));
        System.out.println(item.getAttrValue(2));
        System.out.println(item.getAttrValue(3));
        System.out.println(item.getAttrValue(4));
        formbean.setFormID(FormID);
        String MainDocument=item.getAttrValue(1);
        formbean.setMainDocument(MainDocument);
        String SubDocument=item.getAttrValue(2);
        formbean.setSubDocument(SubDocument);
        formbean.setAppNumber(item.getAttrValue(3));
        formbean.setBranchCode(item.getAttrValue(4));
        formbean.setAdvisor_NAME(item.getAttrValue(5));
        formbean.setAdvisor_Code(item.getAttrValue(6));


         formbeanCol.add(formbean);
         System.out.println("formbeanCol.size() "+formbeanCol.size());


  return formbeanCol;
}
}  

JSP

<display:table name="formbeanCol" export="false" pagesize="20" sort="list" id="data" requestURI="" class="tablelist">

        <display:column title="advisor_Code" sortable="true" property="advisor_Code"></display:column>
        <display:column title="formID" sortable="true" property="formID"></display:column>
        <display:column title="mainDocument" sortable="true" property="mainDocument"></display:column>
        <display:column title="SubDocument" sortable="true" property="subDocument"></display:column>
        <display:column title="AppNumber" sortable="true" property="appNumber"></display:column>
        <display:column title="branchCode" sortable="true" property="branchCode"></display:column>
        <display:column title="advisor_NAME" sortable="true" property="advisor_NAME"></display:column>

</display:table>

below table I get as an output

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:34:06+00:00Added an answer on June 7, 2026 at 10:34 am

    The issue is that you are using the single instance of FormBean (the one that’s passed into the Action by Struts) in getDocumentMetaData. So your collection (formbeanCol) ends up with each entry pointing to the same FormBean instance. So in your last iteration you will be setting the values for this FormBean to the last data row, and all entries point to this.

    I would advise not using FormBean for this (use a simple bean instead), and create a new instance each time in getDocumentMetaData. If you do want to continue to use FormBean then a simple fix is to change getDocumentMetaData as follows:

    public Collection getDocumentMetaData(CMBItem item,FormBean formbean)
    throws CMBException, Exception 
    {
        FormBean bean = new FormBean();
    
        // Get document metadata attributes
        String FormID = item.getAttrValue(0);
        bean.setFormID(FormID);
    
        // etc
    
        formbeanCol.add(bean);
        return formbeanCol;
    }
    

    This issue does highlight the dangers of using ‘global’ variables (in this case formbean and formbeanCol).

    FYI, you should avoid instance variables in Actions as Actions in Struts 1.x are globally scoped, i.e. one instance will be shared between different requests. Your formbeanCol will probably get increasingly large and you may get concurrency issues. Just declare formbeanCol as a local variable in the execute method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I want to get all rows from the customers table that do NOT
I'm trying to get all rows from a table that lie between two dates.
I have the classic 'get all rows in one table with number of corresponding
what is the simplest way to get all rows where a complex condition holds
I have to create an SQL Query to get all rows starting with a
I am trying to get all the rows that exist in allData but not
I'm trying to LEFT JOIN two tables, to get a list of all rows
I'm using jqGrid with the getChangedCells('all') to get an array of the rows in
This code is supposed to get all rows in the range that I specify,
With if in a where statement I'm trying to get all rows where datetime

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.