Update JTable model col through header name in fast way

old day, i update my JTable model through the way :
tableModel.setValueAt(aValue, rowIndex, jTable1.getColumn("HeaderName").getModelIndex());now, i am adding a feature to my table, where the user can remove column.
when user remove the column, is just the JTable GUI column being removed,. the underlining TableModel column is still there.
my new feature will broke my above code.
hence, i change my code to :
for(columnIndex=0; columnIndex<columnCount; columnIndex++) {
     String name = tableModel.getColumnName(columnIndex)
     if(name.equals("HeaderName"))
          tableModel.setValueAt(aValue, rowIndex, columnIndex)
}instead of looping through, is there any way i can retrieve the column model index in a fast way?
a way i can think off, is inherit from DefaultTableModel, and add a map member, so that it can directly map the header name to col index.
is there any better way?
thanks

i don't know why but the KeyListener does work fine with another application that i have also created Not a good solution. First of all the column still exists, so the user will tab from one column to your "hidden" column and wonder whats happening.
The correct solution is to remove the TableColumn from the TableColumnModel. You can still access the data in the TableModel:
table.getModel().getValueAt(...)
No need to use the convertColumnIndexToModel.

Similar Messages

  • Help updating jTable (model?)

    I've got a jTable, which stores information that I retrieve from game servers (player's name, frag count, and time connected to the server). I'll admit first off that I'm very, very new to Swing and still new to Java as a whole. I've searched the forums several times (which is the only reason I got as far as I have) and I've also closely examined the tutorial, API, and examples. I probably have already looked at my answer, but it eludes me. My table doesn't seem to be updating its display or I'm not properly modifying the object's contents because my table will only display empty cells (although the correct number of rows). Here's some snippets of what I've got so far:
    Object[][] data;
    String[] columnNames = {"Name", "Frags", "Time"};
    final DefaultTableModel model;
    data = new Object[64][3];       
    model = new DefaultTableModel(data, columnNames);
    model.setRowCount(0);
    playersListTable = new javax.swing.JTable();
    playersListTable.setModel( model );
    public void updatePlayerInfo() {
            int x = 0;
            if (settings.getServerProp("PlayerInfoNum") != null) {
                model.setRowCount(Integer.valueOf(settings.getServerProp("PlayerInfoNum")));
                while (Integer.valueOf(settings.getServerProp("PlayerInfoNum")) > x) {
                    System.out.println("Updating player info... " + x);
                    data[x][0] = settings.getServerProp("PlayerName" + x);
                    data[x][1] = settings.getServerProp("PlayerScore" + x);
                    data[x][2] = settings.getServerProp("PlayerTime" + x++);
                model.fireTableDataChanged();
        }I'm about to head off to work, so my apologies if I left out important details. I'll be around later to fill in any gaps I mistakenly forgot. Thanks again for the help!
    EDIT: The table gets updated on one second intervals.
    Edited by: mr0ldie on Nov 16, 2008 1:31 PM

    Thank you very much! :) I was very confused on how tables worked--I thought I still had to manage the data myself and the table and model were simply containers and visible settings for that (probably not explaining how I thought of it well, but I didn't fully understand, so explaining is even harder ;). Anyway, I've got it working, thanks to your help!

  • Unable to assign name the fast way

    Hello,
    Switching over to Aperture from iphoto and having a little problem with the face recognition part. When I am in a project on a selected picture and click name (N) the face label comes up. I then have to click the box (with mouse) and write the name, then move over to the next picture and do the same thing.
    My question is how do I select the label via keyboard so I can quickly type the name and move to the other pictures. I remember in iphoto it was tab, but I have tried everything and this is not working for me. Any help would be great since this will save me lots of hassle and time.

    Hi Paul
    I am not able to get your technique to work, also in Aperture 3.0.2.
    I've just now tried it in v3.0.2 on my laptop and find that I share your problem. When I responded earlier, I had been using it on my iMac (my main machine) which is running Aperture v3.0.1. (The alternative explanation of the difference in OS's - 10.5 and 10.6 - is probably less likely.)
    <snip>
    I am not sure what you mean by a passive area of the viewer
    Sorry. I realise in hindsight that this was a poor description. I was meaning for you to click in the border around your photo (probably either left/right or top/bottom) but still inside the viewer. This was rather than clicking on the photo itself, although I've now established that this should not cause any problems. I was thinking of situations where the current tool might not have been the selection tool (the arrow) and perhaps have led to unexpected behaviour. However, it seems that when you press N it cancels Crop, Straighten or whatever tool might have been selected.
    I can't see this change in behaviour being deliberate, so the more people that log it as a bug, the better the chances of it being fixed in the next patch.
    +Aperture > Provide Aperture Feedback+
    Regards,
    Gary

  • JTable help:- Setting Table Header and scrollbar

    hi
    everybody.
    i have create a table which is getting the data from URL Connection by parsing the XML file.
    All is working fine but the only problem is that i am not able to set the column headers.
    and also want to set scrollbars to my table because the data in my table is long.
    i have tried with JTableHeader and TableModel, but i am confused with it.
    so can anybody solve my problem.
    i am sending my code for creating table, and also sending the file from which the data is retrieved.
    please go through the code and reply me.
    If u are not able to parse the xml file than simply removed that part and using the QUERYResp.txt which i have attached, because i think the URL which i am using will not be accessed other than my network
    waiting for reply.
    //SelectPrivilege.java
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.w3c.dom.*;
    import java.net.*;
    import java.util.*;
    public class SelectPrivilege extends JFrame implements ActionListener
         JFrame frame;
         JTable table;
         JPanel buttonpanel;
         JButton openbutton,donebutton;
         String strclassname,strmembertype,strpasswordduration,strclassdescription;
        private boolean ALLOW_ROW_SELECTION = true;
        ListSelectionModel rowSM;
         Document document;
         Node node;
         NodeList employees,children;
         Element employee;
         String inputline,strSuccess;
         URL url;
         URLConnection connection;
         FileInputStream fis;
         DataInputStream dis;
         String objid,classname,membertype,passwordexp,description,finalstring;
         StringTokenizer st;
         String strurl = "<CLFAPP><CLFYAPP_MSG_TYPE_MSG_TYPE>QUERY</CLFYAPP_MSG_TYPE_MSG_TYPE><TABLE>PRIVCLASS</TABLE><FIELDS>OBJID,CLASS_NAME,MEMBER_TYPE,PSWRD_EXP_PER,DESCRIPTION</FIELDS><FILTER></FILTER></CLFYAPP>";
         public SelectPrivilege()
              JFrame.setDefaultLookAndFeelDecorated(true);
              frame = new JFrame("Select Privilege Class");
              try
                   url = new URL("http://10.8.54.55:7002/RILClarifyAppRequest?XML=" + strurl);
                   connection = url.openConnection();
                   BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                   FileOutputStream out = new FileOutputStream("QUERYResp.xml");
                   PrintStream p = new PrintStream(out);
                   while ((inputline = reader.readLine()) != null)
                        System.out.println("Response Received......");
                        p.println(inputline);
                   p.close();
                   reader.close();
              catch(MalformedURLException e)
                   System.out.println(e.getCause());
              catch(IOException e)
                   System.out.println(e.getCause());
              //Parsing XML
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              try
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   document = builder.parse(new File("QUERYResp.xml"));
                   node = document.getDocumentElement();
                   employees = document.getElementsByTagName("RECORD");
                   FileOutputStream out = new FileOutputStream("QUERYResp.txt");
                   PrintStream p = new PrintStream(out);
                   for(int i = 0; i < employees.getLength(); i++)
                        final Element employee = (Element)employees.item(i);
                        p.print(getValueOf(employee,"OBJID"));
                        p.print("#");
                        p.print(getValueOf(employee,"CLASS_NAME"));
                        p.print("#");
                        p.print(getValueOf(employee,"MEMBER_TYPE"));
                        p.print("#");
                        p.print(getValueOf(employee,"PSWRD_EXP_PER"));
                        p.print("#");
                        p.print(getValueOf(employee,"DESCRIPTION"));
                        p.print("#@");
                        //p.close();
                        objid = getValueOf(employee,"OBJID");
                        classname = getValueOf(employee,"CLASS_NAME");
                        membertype = getValueOf(employee,"MEMBER_TYPE");
                        passwordexp = getValueOf(employee,"PSWRD_EXP_PER");
                        description = getValueOf(employee,"DESCRIPTION");
              catch(SAXException sxe)
                   Exception x = sxe;
                   if(sxe.getException() != null)
                        x = sxe.getException();
                   x.printStackTrace();
              catch(ParserConfigurationException pce)
                   pce.printStackTrace();
              catch(IOException ioe)
                   ioe.printStackTrace();
              catch(NullPointerException npe)
                   System.out.println(npe.getCause());
              table();
              buttonpanel = new JPanel();
              buttonpanel.setLayout(new FlowLayout());
              openbutton = new JButton("Open");
              donebutton = new JButton("Done");
              donebutton.setMnemonic('d');
              buttonpanel.add(openbutton);
              buttonpanel.add(donebutton);
              openbutton.addActionListener(this);
              donebutton.addActionListener(this);
              Container contentpane = getContentPane();
              frame.setContentPane(contentpane);
              contentpane.setLayout(new BorderLayout());
              contentpane.add(table.getTableHeader(),BorderLayout.PAGE_START);
              contentpane.add(table,BorderLayout.CENTER);
              contentpane.add(buttonpanel,BorderLayout.SOUTH);
              frame.setSize(500,400);
              frame.setVisible(true);
         static String getValueOf (Element element, String tagname)
              final NodeList children = element.getElementsByTagName(tagname);
              if (children.getLength() == 0) { return null; }
                   return concat(children, new StringBuffer()).toString();
         static StringBuffer concat (NodeList nodelist, StringBuffer buffer)
              for (int index = 0, length = nodelist.getLength(); index < length; index++)
                   final Node node = nodelist.item(index);
                   switch (node.getNodeType())
                        case Node.CDATA_SECTION_NODE: buffer.append(node.getNodeValue()); break;
                        case Node.ELEMENT_NODE: concat(node.getChildNodes(), buffer); break;
                        case Node.TEXT_NODE : buffer.append(node.getNodeValue()); break;
              return buffer;
         public void table()
              try
                   fis = new FileInputStream("QUERYResp.txt");
                   dis = new DataInputStream(fis);
                   finalstring = dis.readLine();
              catch(IOException e)
              st = new StringTokenizer(finalstring, "@");
              table = new JTable(st.countTokens() + 1,5);
              table.setValueAt("OBJID",0,0);
              table.setValueAt("CLASS NAME",0,1);
              table.setValueAt("MEMBER TYPE",0,2);
              table.setValueAt("PASSWORD DURATION",0,3);
              table.setValueAt("DESCRIPTION",0,4);
              int count = 0,cnt=0;
              StringTokenizer st1 = null;
              try
                   while(st.hasMoreTokens())
                        st1 = new StringTokenizer(st.nextToken(),"#");
                        cnt=0;
                        while(st1.hasMoreTokens())
                             table.setValueAt(st1.nextToken(),count,cnt++);
                        count++;
                        st1=null;
              catch(Exception e)
                   e.printStackTrace();
              //JTableHeader header = table.getTableHeader();
              table.setPreferredScrollableViewportSize(new Dimension(200,500));
            table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            if(ALLOW_ROW_SELECTION)
                 rowSM = table.getSelectionModel();
                 rowSM.addListSelectionListener(new ListSelectionListener(){
                            public void valueChanged(ListSelectionEvent e)
                                 ListSelectionModel row = (ListSelectionModel)e.getSource();
                                 if (row.isSelectionEmpty() == true)
                                    System.out.println("No rows are selected.");
                                else
                                     if (e.getValueIsAdjusting())
                                          return;
                                         int selectedRow = row.getMinSelectionIndex();
                                         System.out.println("Row " + selectedRow + " is now selected.");
                 JScrollPane scrollpane = new JScrollPane(table);
         public void createprivilegeclassdetails()
              PrivilegeClassDetails privilegeclassdetailsobj = new PrivilegeClassDetails();
              privilegeclassdetailsobj.frame.setSize(400,400);
              privilegeclassdetailsobj.frame.setVisible(true);
         public void actionPerformed(ActionEvent ae)
              String str = ae.getActionCommand();
              if(str.equalsIgnoreCase("done"))
                   System.out.println("SelectPrivilege Window Closed");
                   frame.dispose();
              if(str.equalsIgnoreCase("open"))
                   System.out.println("here");
                   createprivilegeclassdetails();
         public static void main(String a[])
              new SelectPrivilege();
    Copy the whole line if ur saving this in a file, as it is a string
    //QUERYResp.txt
    268435457#CSR#Employees#0#Customer Support Representative#@268435458#Hotline Engineer#Employees#0#Hotline Engineer#@268435459#Product Specialist#Employees#0#Product Specialist#@268435460#Senior Product Specialist#Employees#0#Senior Product Specialist#@268435461#Field Engineer#Employees#0#Field Engineer#@268435462#Support Manager I#Employees#0#Support Manager I#@268435463#Support Manager II#Employees#0#Support Manager II#@268435464#Development Engineer#Employees#0#Development Engineer#@268435465#Development Manager#Employees#0#Development Manager#@268435466#QA Engineer#Employees#0#QA Engineer#@268435467#QA Manager#Employees#0#QA Manager#@268435468#Technical Writer#Employees#0#Technical Writer#@268435469#Technical Publications Manager#Employees#0#Technical Publications Manager#@268435470#Site Configuration Manager#Employees#0#Site Configuration Manager#@268435471#Product Administrator#Employees#0#Product Administrator#@268435472#Technical Product Administrator#Employees#0#Technical Product Administrator#@268435473#Contract Specialist#Employees#0#Contract Specialist#@268435474#System Administrator#Employees#90#System Administrator#@268435475#Submitter#Contacts#0#Submitter#@268435476#Viewer#Contacts#0#Viewer#@268435477#Inventory Specialist#Employees#0#Inventory Specialist#@268435478#Logistics Manager#Employees#0#Logistics Manager#@268435479#Sales Representative#Employees#0#Sales Representative#@268435480#Marketing Representative#Employees#0#Marketing Representative#@268435481#Sales Manager#Employees#0#Sales Manager#@268435482#Offline User#Employees#0#Privilege Class for use with ClearEnterprise Traveler#@268435483#Call Center Agent#Employees#30#Call Center Agent#@268435484#Call Center Manager#Employees#0#Call Center Manager#@268435485#Customer Service Agent#Employees#0#Customer Service Agent#@268435486#Telemarketing Agent#Employees#0#Telemarketing Agent#@268435487#Telesales Agent#Employees#0#Telesales Agent#@268435488#Telesales Manager#Employees#0#Telesales Manager#@268435489#Avaya_Users#Employees#0#Privilege Class for Avaya. Only Clear Call Center Application Enabled.#@268435490#Account Manager#Employees#0#Account Manager for Accounts#@268435491#Account Executive#Employees#30#Account Executive for Accounts#@268435492#Pre Sales Tech Executive#Employees#0#Pre Sales Technical Executive#@268435493#Pre Sales Tech Team Lead#Employees#0#Pre Sales Technical Team Leader#@268435494#Post Sales Tech Executive#Employees#0#Post sales technical executive#@268435495#Post Sales Commercial Executive#Employees#0#Post sales commercial executive#@268435496#Vertical Domain Expert#Employees#0#Vertical Domain Expert#@268435497#Supervisor#Employees#0#Supervior who approves the billing adjustments#@268435498#RA#Employees#0##@268435499#Configuration#Employees#90#Privilege Class for Clarify Configurators#@268435500#FO Online Agent#Employees#0#Testing#@268435501#OTAF Remote Funcionality#Employees#0##@268435502#Sr.Manager CC#Employees#0#Customization for phase1 RUNS (1a).#@268435503#FO Online Unit - Agent #Employees#0#Customization for phase1 RUNS (1).#@268435504#FO Online - Agent (outbound)#Employees#0#Customization for phase1 RUNS (1b).#@268435505#Incoming mail unit manager#Employees#0#Customization for phase1 RUNS (2).#@268435506#Save team agent#Employees#0#Customization for phase1 RUNS (3).#@268435507#Save team supervisor#Employees#0#Customization for phase1 RUNS (4).#@268435508#Technical suport agent#Employees#0#Customization for phase1 RUNS (5).#@268435509#Technical suport supervisor#Employees#0#Customization for phase1 RUNS (6).#@268435510#Webstore Agents#Employees#0#Customization for phase1 RUNS (7).#@268435511#FO Offline Unit (Reg)- Supervisor#Employees#0#Customization for phase1 RUNS (8).#@268435512#Head C. Service (Circles)#Employees#0#Customization for phase1 RUNS (8a).#@268435513#Revenue Assurance#Employees#0#Customization for phase1 RUNS (9).#@268435514#Manager CC#Employees#0#Customization for phase1 RUNS (1a).#@268435515#FO Offline Unit - Agent at Contact Centre#Employees#0#Customization for phase1 RUNS (1).#@268435516#Telesales unit agent#Employees#0#Customization for phase1 RUNS (1).#@268435517#Incoming mail unit agent#Employees#0#Customization for phase1 RUNS (1).#@268435518#Telesales supervisor#Employees#0#Customization for phase1 RUNS (2).#@268435519#FO Online Unit - Supervisor#Employees#0#Customization for phase1 RUNS (2).#@268435520#FO Offline Unit (CC) - Supervisor#Employees#0#Customization for phase1 RUNS (2).#@268435521#TT unit agent#Employees#0#Customization for phase1 RUNS (5).#@268435522#TT unit supervisor#Employees#0#Customization for phase1 RUNS (6).#@268435523#Pos Agents#Employees#0#Customization for phase1 RUNS (7).#@268435524#FO Offline Unit - Regions#Employees#0#Customization for phase1 RUNS (7).#@268435525#Service fulfillment unit agent#Employees#0#Customization for phase1 RUNS (7).#@268435526#Sales Executives (Regions)#Employees#0#Customization for phase1 RUNS (7).#@268435527#Webstore Manager#Employees#0#Customization for phase1 RUNS (8).#@268435528#Service fulfillment unit manager#Employees#0#Customization for phase1 RUNS (8).#@268435529#Network#Employees#0#Customization for phase1 RUNS (9).#@268435530#After Sales#Employees#0#Customization for phase1 RUNS (9).#@268435531#Handsets#Employees#0#Customization for phase1 RUNS (9).#@268435532#Portal#Employees#0#Customization for phase1 RUNS (9).#@268435533#GIS#Employees#0#Customization for phase1 RUNS (9).#@268435534#Logistics#Employees#0#Customization for phase1 RUNS (9).#@268435535#Data Services#Employees#0#Customization for phase1 RUNS (9).#@268435536#Production Support#Employees#0#Since it is possible to temper the data form the Clarify GUI , restrict all access to users except for the minimal in order to control the env.#@268435537#Webstore Users#Employees#0##@268435539#IN_CSR#Employees#0#Privilege Class for Prepaid CSR's#@268435540#Configuration_Maha#Employees#0#Privilege Class for Clarify Configurators#@268435541#test privilege class#Employees#0##@268435542#PS_TEST#Employees#0##@268435543#TEST SACHIN#Employees#0#SACHIN TEST#@268435544#Supervisor1#Employees#300#Supervise and monitor agents#@268435545#Call Center Adminstrator#Employees#0#Call Center Admin Priv#@268435546#siva_test#Employees#0#new privilege class for test purpose#@268435547#PREPAID PCO#Employees#0#For PREPAID PCO#@268435548#santo_test#Employees#0#new privilage class for test#@

    Don't start by writing a 100 line program to test a component you don't know how to use. Start by writing a 10 line program. This is all you need:
              String[] columnNames = {"Date", "String", "Centered", "Integer", "Boolean"};
              Object[][] data =
                   {new Date(), "A", "A", new Integer(1), new Boolean(true)},
                   {new Date(), "B", "B", new Integer(2), new Boolean(false)},
                   {new Date(), "C", "C", new Integer(10), null},
                   {new Date(), "D", "D", new Integer(4), new Boolean(false)}
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              model.addTableModelListener( this );
              table = new JTable( model )
                   //  Returning the Class of each column will allow different
                   //  renderers to be used based on Class
                   public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
              table.setPreferredScrollableViewportSize(table.getPreferredSize());
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );

  • AP to GL Transfer: How to have a custom Journal Header name in GL.

    Hi,
    Does any one know how to have a custom Journal Header name while transferring the Journals from AP to GL?
    Assume that I am transferring the Journals which belongs to a Single Invoice from AP to GL. When these Journals are transferred from AP to GL, Oracle will create a Journal Header with the default naming convention. The Oracle generated Header name will be as shown below.
    *123456 Purchase Invoices USD*. Where 123456 is AE_HEADER_ID and USD is the Invoice Currency code.
    Our requirement is, we want the Journal Header name something like *"Hello World"+TIMESTAMP*, where TIMESTAMP is the date when the user has ran the AP to GL transfer program.
    I know that when building the AAD(Application Accounting Definition) we can define the Journal Header descriptions and Journal Lines descriptions. But, I did not see any setup option to have the custom Journal Header name in GL.
    Any suggestions on this issue are highly appreciated.
    Advanced Thanks,
    Lokesh.

    Hi Lokesh,
    The best way to have a custom journal header name is using hook package.
    When data move from XLA to GL, every time it creates a new dynamic table as GL_INTERFACE table but the name is different (XLA_GLT_XXXXX).
    This table information stores in 'gl_interface_control' table but after use the record has deleted from 'gl_interface_control'.
    So we can't see table information after finishing create accounting program.
    What the modification you will made in this table it will affect GL base table. So to made custom journal header name, we need to change Reference4 column of dynamic table.
    Here is the code to get the table name and through procedure you can update the Reference4 column.
    FUNCTION pre_module_hook(run_id IN NUMBER,
                   errbuf IN OUT NOCOPY VARCHAR2) RETURN BOOLEAN IS
    chr_errbuf varchar2(50);
    chr_retcode varchar2(50);
    l_interface_Table_name varchar2(2000);
    BEGIN
         SELECT interface_table_name
    into l_interface_Table_name
    FROM gl_interface_control
    WHERE interface_run_id = run_id;
         BEGIN     
    xxdb_gl_icaccntgdist_pkg.gl_int_jrnl_update (chr_errbuf,chr_retcode,l_interface_Table_name);
    RETURN(TRUE);
         END;
    END pre_module_hook;
    Make these changes in GL_IMPORT_HOOK_PKG.pre_module_hook function.
    You can make the changes through calling procedure using dynamic query under the function pre_module_hook.
    Thanks,
    Gaurav K
    Edited by: 972729 on Nov 22, 2012 4:46 AM

  • Struts2 - ScopedModelDriven - Unable to update the model in session

    Hi,
    I have a problem implementing ScopedModelDriven.
    I Have Model / User Java Bean object in action class.
    I am trying to implement concept of same model object being used for 3 JSP pages with PREVIOUS and NEXT button navigation.Data to be updated in Model object for every page navigation and to be saved in session.
    It is found the latest data is found from value stack when jsp page is navigated to next page, but not updated in Model object either in request or session scope I am sure I have configured necessary interceptors properly.
    This could be easily done in struts1 by setting the Actionform in session scope.Any advice or thought?.
    Struts.xml:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />
    <package name="myPackage" namespace="/" extends="struts-default">
    <interceptors>
    <interceptor name="myMultipleForm"
    class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor">
    <param name="scope">session</param>
    <param name="name">user</param>
    <param name="className">com.ut.p.s2.beans.User</param>
    </interceptor>
    </interceptors>
    <global-results>
    <result name="error">/jsp/Error.jsp</result>
    <result name="invalid.token">/jsp/Error.jsp</result>
    <result name="login">/jsp/login.jsp</result>
    </global-results>
    <global-exception-mappings>
    <exception-mapping
    result="error"
    exception="java.lang.Throwable"/>
    </global-exception-mappings>
    <action name="ShowScopedModel" class="com.ut.p.s2.actions.ServletTestAction" >
    <interceptor-ref name="servletConfig"/
    <interceptor-ref name="app_common"/>
    <result name="model_test_page">/jsp/smodelTest.jsp</result>
    <result>/jsp/smodelTest.jsp</result>
    </action>
    <action name="scopedModelAction_*" class="com.ut.p.s2.actions.ScopedModelDrivenAction" method="{1}">
    <interceptor-ref name="basicStack"/>
    <interceptor-ref name="defaultStack" />
    <interceptor-ref name="prepare"/>
    <interceptor-ref name="debugging"/>
    <interceptor-ref name="scopedModelDriven">
    <param name="scope">session</param>
    <param name="name">user</param>
    <param name="className">com.ut.p.s2.beans.User</param>
    </interceptor-ref>
    <interceptor-ref name="params"/>
    <interceptor-ref name="conversionError"/>
    <interceptor-ref name="workflow"/>
    <result name="input">/jsp/smodelTest.jsp</result>
    <result>/jsp/smodelResult.jsp</result>
    <result name="model_test_page">/jsp/smodelTest.jsp</result>
    <result name="model_test_page2">/jsp/smodelTest2.jsp</result>
    <result name="model_test_page3">/jsp/smodelTest3.jsp</result>
    <result name="model_result_page">/jsp/smodelResult.jsp</result>
    </action>
    </package>
    </struts>
    Action:
    package com.ut.p.s2.actions;
    import java.util.ArrayList;
    import com.ut.p.s2.beans.Books;
    import com.ut.p.s2.beans.Dept;
    import com.ut.p.s2.beans.User;
    import com.opensymphony.xwork2.ActionSupport;
    import com.opensymphony.xwork2.Preparable;
    import com.opensymphony.xwork2.interceptor.ScopedModelDriven;
    public class ScopedModelDrivenAction extends ActionSupport implements ScopedModelDriven,Preparable {
    private User user =null;
    private static final long serialVersionUID = 1271130427666936592L;
    private String scope = null;
    public void prepare() throws Exception {
    user = new User();
    ArrayList arlList=new ArrayList();
    Books b1 = new Books("Java",100);
    Books b2 = new Books("VB",200);
    arlList.add(b1);
    arlList.add(b2);
    Dept dept = new Dept();
    dept.setDeptNo("100");
    dept.setDeptName("Mechanical");
    user.setDept(dept);
    user.setArlList(arlList);
    public String getScopeKey() {
    return scope;
    public void setModel(Object arg0) {
    this.user = (User) arg0;
    public void setScopeKey(String arg0) {
    scope = arg0;
    public Object getModel() {
    return user;
    public User getUser() {
    return user;
    public void setUser(User user) {
    this.user = user;
    public String execute() {
    System.out.println("execute()........."+user);
    return INPUT;
    public String input() throws Exception {
    System.out.println("input()........."+user);
    return SUCCESS;
    public String save() {
    System.out.println("save()........."+user);
    return "model_result_page";
    public String page1() {
    System.out.println("page1()........."+user);
    System.out.println("page1()....scope....."+scope);
    return "model_test_page";
    public String page2() {
    System.out.println("page2()........."+user);
    System.out.println("page2()....scope....."+scope);
    return "model_test_page2";
    public String page3() {
    System.out.println("page3()........."+user);
    System.out.println("page3()....scope....."+scope);
    return "model_test_page3";
    }//end class
    JSP Page:
    <%@ page errorPage="/jsp/Error.jsp" %>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@taglib uri="/struts-tags" prefix="s" %>
    <html>
    <head>
    <s:head theme="simple"/>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>User Details</title>
    </head>
    <body>
    <h2>User Details</h2>
    <hr>
    User Name :<s:property value="name" /><br>
    Age :<s:property value="age" /><br>
    Hobbies :<s:property value="hobby" /><br>
    Country :<s:property value="country" /><br>
    <TABLE border="1">
    <s:iterator value="arlList" status="row">
    <TR>
    <TD><s:textfield name="arlList[%{#row.index}].name" value="%{name}" /></TD>
    <TD> <s:text name="arlList[%{#row.index}].price" /></TD>
    </TR>
    </s:iterator>
    </TABLE>
    <h2>
    User Department :<s:property value="dept" /><br>
    <s:property value="dept.id" />
    <s:property value="dept.name" />
    <jsp:include page="Footer.jsp"/>
    </body>
    </html>

    I am very surprised that you aren't aware of the CODE tags after being registered here for 5 years. Now your whole post with raw and unformatted code is hard to read. Make use of CODE tags to post code. You can use the CODE button in the toolbar of the message editor to get them.
    With regard to your actual problem: as this is a Struts specific issue and you're here at a JSP forum, all I can do is to suggest you to use a forum/mailinglist devoted to Struts if you don't get sufficient support here after a while.

  • Clear and update JTable.

    Hi. this is a follow up from [Original Tread in "New To Java"|http://forums.sun.com/thread.jspa?messageID=10886612&#65533;]
    Hope you can help me here. For you who dont read the link. This application is build only to lay up here. So the Layout aint pretty. It compiles and run tho. What i want and cant get to work is to reload table when i push my JTabbedPane.
    Main Class
    package test;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Main {
        public Main() {
            run();
        public void run(){
         frame();
        // clear and update JTable in class three
        public void clearThree() {
            Three t = new Three();
             t.clearVector();
        public JFrame frame() {
            JFrame frame = new JFrame();
            JTabbedPane tab = new JTabbedPane();
            tab.addTab("two",new Two());
            tab.addTab("three", new Three());
            tab.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    clearThree();// this dont work
            frame.add(tab);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(800,400);
             frame.setVisible(true);
             frame.pack();
            return frame;
        public static void main(String[] args) {
             java.awt.EventQueue.invokeLater(new Runnable() {
                         public void run(){
           new Main();
    }// class two
    package test;
    import java.awt.event.*;
    import java.util.Vector;
    import javax.swing.*;
    // class two&#347; only purpose is to  call clear() in class Three
    public class Two extends JPanel{
    public Two(){
    toolBar();
      public void clearThree () {
       Three t = new Three();
       t.clearVector();
      public void toolBar(){
      JToolBar bar = new JToolBar();
      JButton button = new JButton("clear");
      button.addActionListener(new ActionListener (){
          public void actionPerformed(ActionEvent e){
          clearThree(); // this dont work
    bar.add(button);
    add(bar);
    }// class three hold the table.
    package test;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Vector;
    import javax.swing.*;
    import javax.swing.table.DefaultTableModel;
    public class Three extends JPanel{ 
            DefaultTableModel model;
            JTable table;
            Vector v = new Vector();
            Vector a = new Vector();
            Vector<Vector> r = new Vector<Vector>();
        public Three() {
            jBar();
            jTable();
        public void clearVector(){
            v.removeAllElements();
            a.removeAllElements();
            r.removeAllElements();
            model.fireTableDataChanged();
        public void jBar() {
            JToolBar bar = new JToolBar();
            JButton button =  new JButton("clear");
            button.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    clearVector();// this does work
            bar.add(button);
            add(bar);
        public JScrollPane jTable(){
            v.addElement("ID");
            v.addElement("Name");
            a.addElement("01");
            a.addElement("Magnus");
            r.add(a);
            model = new DefaultTableModel(r,v);
            table = new JTable(model);
             JScrollPane pane = new JScrollPane(table);
             add(pane);
             return pane;
    }

    Thank you for your replay, I have taken all of your tips and modifed my original application. but the problem is still there. This has been a very messy thread. and it is becouse i thougth it were a table/model problem. But it&#347; not. In the code below I have a JTextField. When i push the JTabbedPanes i want the setText(); to kick in. this compile and run.
    // class One
    package test;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Main {
        public Main() {
            run();
        public void run(){
         frame();
        public JFrame frame() {
            JTabbedPane tab = new JTabbedPane();
            final  Three t = new Three();
            JFrame frame = new JFrame();
            JPanel panel = new JPanel();
            tab.addTab("two",new Two());
            tab.addTab("three", new Three());
            tab.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                      t.setText(); // should call setText() in class Three.
            frame.add(panel);
            frame.add(tab);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(800,400);
             frame.setVisible(true);
             frame.pack();
            return frame;
        public static void main(String[] args) {
             java.awt.EventQueue.invokeLater(new Runnable() {
                         public void run(){
           new Main();
    }class Two. Does nothing more then holding an empty tab
    package test;
    import javax.swing.*;
    public class Two extends JPanel{
    public Two(){
    emptyPane();
      public void emptyPane () {
      JLabel  label = new JLabel("Just an empty JTabbedPane");
      add(label);
      }class Three
    package test;
    import javax.swing.*;
    public class Three extends JPanel{ 
             JTextField text;
        public Three() {
            text();
        public void setText() {
            text.setText("Hello"); // this piece of code i want to insert in my JTextField
            validate();                // when i push the JTabbedPanes.
            repaint();
            updateUI();
        public JTextField text(){
             JToolBar bar = new JToolBar();
            text = new JTextField("",20);
            bar.add(text);
            add(bar);
            return text;
    }

  • Unable to update payment cards data through ORDERS05 in va02

    Hi all,
    I noticed one thing that in IDOC_INPUT_ORDERS (ie creation of sales order)  we have a bdcdata populated for payment cards (for header in VA01) .But when we are changing sales order by IDOC_INPUT_ORDCHG (change sales order VA02) we have no bdcdata populated for updating payment cards ( like CCNUM ) though we are passing these details through IDOC.
    Can anyone tell me why bdcdata through idoc posting is getting populated in VA01 but not through VA02 . We can change payment card dara manually in VA02  why cant we achieve the same through idoc.
    Please help me as updating payment card data through idoc in VA02 is my requirement .
    Do i need to populate it by writing code in an exit in IDOC_INPUT_ORDCHG.
    Any help is appreciated.
    Thanks and Regards
    Sweta

    Hi,
    Can you please let me know the segment in ORDERS05 Idoc to process the Payment card information and if the standard Function Module can handle the creation of a Sales Order with data for Payment Card.
    We have a requirement to map the Tokenized Number of the Credit Card send from a store front end to ECC mapping via SAP-PI.
    Thanks in Advance,

  • JTable can't display column names and scroll bar in JDialog !!

    Dear All ,
    My flow of program is JFrame call JDialog.
    dialogCopy = new dialogCopyBay(frame, "Bay Name Define", true, Integer.parseInt(txtSourceBay.getText()) ,proVsl ,300 ,300);
    dialogCopy.setBounds(0, 0, 300, 300);
    dialogCopy.setVisible(true);        Then,I set the datasource of JTable is from a TableModel.
    It's wild that JTable can diplay the data without column names and scroll bar.
    I have no idea what's going wrong.Cause I follow the Sun Tutorial to code.
    Here with the code of my JDialog.
    Thanks & Best Regards
    package com.whl.panel;
    import com.whl.vslEditor.vslDefine;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Frame;
    import javax.swing.JDialog;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    public class dialogCopyBay extends JDialog {
        vslDefine glbVslDefine;
        int lvCnt = -1;
        JTable tableCopyBay;
        int bgnX = 0;
        int bgnY = 30;
        int tableWidth = 100;
        int tableHeight = 100;
        public dialogCopyBay(Frame frame, String title, boolean modal, int sourceBay,
                vslDefine pVslDefine, int ttlWidth, int ttlHeight) {
            super(frame, title, true);
            Container contentPane = getContentPane();
            System.out.println("dialogCopyBay Constructor");
            glbVslDefine = null;
            glbVslDefine = pVslDefine;
            copyBayModel copyBay = new copyBayModel((glbVslDefine.getVslBayStructure().length - 1),sourceBay);
            tableCopyBay = new JTable(copyBay);
            tableCopyBay.setPreferredScrollableViewportSize(new Dimension(tableWidth, tableHeight));
            JScrollPane scrollPane = new JScrollPane(tableCopyBay);
            scrollPane.setViewportView(tableCopyBay) ;
            tableCopyBay.setFillsViewportHeight(true);
            tableCopyBay.setBounds(bgnX, bgnY, tableWidth, tableHeight);
            tableCopyBay.setBounds(10, 10, 100, 200) ;
            contentPane.setLayout(null);
            contentPane.add(scrollPane);
            contentPane.add(tableCopyBay);
        class copyBayModel extends AbstractTableModel {
            String[] columnNames;
            Object[][] dataTarget;
            public copyBayModel(int rowNum ,int pSourceBay) {
                columnNames = new String[]{"Choose", "Bay Name"};
                dataTarget = new Object[rowNum][2];
                for (int i = 0; i <= glbVslDefine.getVslBayStructure().length - 1; i++) {
                    if (pSourceBay != glbVslDefine.getVslBayStructure().getBayName() &&
    glbVslDefine.getVslBayStructure()[i].getIsSuperStructure() == 'N') {
    lvCnt = lvCnt + 1;
    dataTarget[lvCnt][0] = false;
    dataTarget[lvCnt][1] = glbVslDefine.getVslBayStructure()[i].getBayName();
    System.out.println("lvCnt=" + lvCnt + ",BayName=" + glbVslDefine.getVslBayStructure()[i].getBayName());
    public int getRowCount() {
    return dataTarget.length;
    public int getColumnCount() {
    return columnNames.length;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int rowIndex, int columnIndex) {
    return dataTarget[rowIndex][columnIndex];
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    public boolean isCellEditable(int row, int col) {
    if (col == 1) {
    // Bay Name Not Allow To modify
    return false;
    } else {
    return true;
    public void setValueAt(Object value, int row, int col) {
    dataTarget[row][col] = value;
    fireTableCellUpdated(row, col);

    Dear DB ,
    I am not sure what you mean.
    Currently,I don't undestand which code is error.
    And I also saw some example is add JTable and JScrollPane in JDialog.
    Like Below examle in Sun tutorial
    public class ListDialog extends JDialog implements MouseListener, MouseMotionListener{
        private static ListDialog dialog;
        private static String value = "";
        private JList list;
        public static void initialize(Component comp,
                String[] possibleValues,
                String title,
                String labelText) {
            Frame frame = JOptionPane.getFrameForComponent(comp);
            dialog = new ListDialog(frame, possibleValues,
                    title, labelText);
         * Show the initialized dialog. The first argument should
         * be null if you want the dialog to come up in the center
         * of the screen. Otherwise, the argument should be the
         * component on top of which the dialog should appear.
        public static String showDialog(Component comp, String initialValue) {
            if (dialog != null) {
                dialog.setValue(initialValue);
                dialog.setLocationRelativeTo(comp);
                dialog.setVisible(true);
            } else {
                System.err.println("ListDialog requires you to call initialize " + "before calling showDialog.");
            return value;
        private void setValue(String newValue) {
            value = newValue;
            list.setSelectedValue(value, true);
        private ListDialog(Frame frame, Object[] data, String title,
                String labelText) {
            super(frame, title, true);
    //buttons
            JButton cancelButton = new JButton("Cancel");
            final JButton setButton = new JButton("Set");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    ListDialog.dialog.setVisible(false);
            setButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    ListDialog.value = (String) (list.getSelectedValue());
                    ListDialog.dialog.setVisible(false);
            getRootPane().setDefaultButton(setButton);
    //main part of the dialog
            list = new JList(data);
            list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            list.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        setButton.doClick();
            JScrollPane listScroller = new JScrollPane(list);
            listScroller.setPreferredSize(new Dimension(250, 80));
    //XXX: Must do the following, too, or else the scroller thinks
    //XXX: it's taller than it is:
            listScroller.setMinimumSize(new Dimension(250, 80));
            listScroller.setAlignmentX(LEFT_ALIGNMENT);
    //Create a container so that we can add a title around
    //the scroll pane. Can't add a title directly to the
    //scroll pane because its background would be white.
    //Lay out the label and scroll pane from top to button.
            JPanel listPane = new JPanel();
            listPane.setLayout(new BoxLayout(listPane, BoxLayout.Y_AXIS));
            JLabel label = new JLabel(labelText);
            label.setLabelFor(list);
            listPane.add(label);
            listPane.add(Box.createRigidArea(new Dimension(0, 5)));
            listPane.add(listScroller);
            listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    //Lay out the buttons from left to right.
            JPanel buttonPane = new JPanel();
            buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
            buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
            buttonPane.add(Box.createHorizontalGlue());
            buttonPane.add(cancelButton);
            buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
            buttonPane.add(setButton);
    //Put everything together, using the content pane's BorderLayout.
            Container contentPane = getContentPane();
            contentPane.add(listPane, BorderLayout.CENTER);
            contentPane.add(buttonPane, BorderLayout.SOUTH);
            pack();
        public void mouseClicked(MouseEvent e) {
            System.out.println("Mouse Click");
        public void mousePressed(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseReleased(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseEntered(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseExited(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseDragged(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseMoved(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
         * This is here so that you can view ListDialog even if you
         * haven't written the code to include it in a program.
    }

  • How to Change Journal Header name to Custom Header Name while GL Importing?

    Hello Experts,
    I am in situation where customer wanted to keep their own journal header naming conventions to imported journals in Oracle GL for custom Journal sources.
    As I know while importing journals, Oracle Creates the Journal Name based on the below mentioned logic.
    "Journal Import creates a default journal entry name using the following format:
    (Optional User-Entered REFERENCE4)(Category Name)(Currency)
    (Currency Conversion Type, if applicable)
    (Currency Conversion Rate, if applicable)
    (Currency Conversion Date, if applicable) (Encumbrance Type ID, if applicable)
    (Budget VersionID, if applicable). If you enter a journal entry name,
    Journal Import prepends the first 25 characters of your journal entry name to
    the above format"
    But then How it is possible to only allow journal header Name to be used present in REFERENCE4 excluding all other string provided by Oracle? Instead of using omitted string custmoer wanted to keep their own parameters. Example - REFERENCE4.A.B.C etc.
    Is it possible to solve this using seeded setup or modifying some hook packages or anything else?
    As far as I know there can be one workaround to be use of updating journal header name after journal import being completed successfully for custom journal source. But only fear is Oracle doesnt allow updating the base table without API. Am I rght?
    So it would be really great if anyone of you can suggest the best solution or best possible workaround.
    Thanks

    Duplicate - How to Change Journal Header name to Custom Header Name while GL Importing?

  • Update JTable

    Hello,
    I always thought that the table takes care for the view, whereas the tablemodel handles the data. But how come that an update with tblModel.setDataVector(...) destroys (resets to default) the preferred column width? Rather how can this be avoided?
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    public class UpdateTable
    { static String headers[]= {"Baum", "Blatt", "Frucht","H�usigkeit"};;
      static String data[][]= {
         {"Eiche", "gez�hnt","Eichel","ein"},
         {"Buche", "glatt", "Buchecker","ein"},
         {"Tanne", "Nadel", "Zapfen","ein"},
         {"Pappel", "wechselst�ndig","Kapsel","zwei"},
      static DefaultTableModel tblModel;
      public UpdateTable()
      { JFrame frame = new JFrame("UpdateTable");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container contentPane = frame.getContentPane();
        tblModel = new DefaultTableModel(data, headers)
        { // Make read-only
          public boolean isCellEditable(int x, int y)
          { return false;
        final JTable table = new JTable(tblModel);
        table.getColumnModel().getColumn(1).setPreferredWidth(200);
        table.getColumnModel().getColumn(3).setPreferredWidth(20);
          // Set selection to first row
        ListSelectionModel selectionModel = table.getSelectionModel();
        selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        selectionModel.addListSelectionListener (new ListSelectionListener()
        { public void valueChanged(javax.swing.event.ListSelectionEvent e)
          { if (e.getValueIsAdjusting()) return;
                System.out.println(table.getSelectedRow());
          // Add to screen so scrollable
        JScrollPane scrollPane = new JScrollPane (table);
        contentPane.add(scrollPane, BorderLayout.CENTER);
        frame.setSize(500, 100);
        frame.setVisible(true);
      public static void main(String args[])
      { new UpdateTable();
        try
        { Thread.sleep(3000);
        catch (InterruptedException e)
        { System.out.println ("Fehler: "+ e.toString());
        String headers_neu[] = {"Arbre", "Feuille", "Fruit", "Maisonette"};
    //  Even if the next line is taken out the width changes.
        headers = headers_neu;
        tblModel.setDataVector((Object[][])data, (Object[])headers);
    }Bye
    J�rg

    I agree, it doesn't make sense. Why does a setDataVector() method need a data vector and a column vector. Anyway I extended the DefaultTableModel and added a refreshDataVector() method that only needs a data vector.
    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class RefreshTableModel extends DefaultTableModel
        public RefreshTableModel()
            super();
        public RefreshTableModel(int numRows, int numColumns)
            super(numRows, numColumns);
        public RefreshTableModel(Object[][] data, Object[] columnNames)
            super(data, columnNames);
        public RefreshTableModel(Object[] columnNames, int numRows)
            super(columnNames, numRows);
        public RefreshTableModel(Vector columnNames, int numRows)
            super(columnNames, numRows);
        public RefreshTableModel(Vector data, Vector columnNames)
            super(data, columnNames);
        public void refreshDataVector(Vector data)
            fireTableRowsDeleted(0, getRowCount() - 1);
            dataVector = data;
            fireTableRowsInserted(0, getRowCount() - 1);
        public void refreshDataVector(Object[][] data)
            refreshDataVector( convertToVector(data) );
        public static void main(String[] args)
            Object[][] data = { {"four", "A"}, {"three", "B"}, {"two", "C"}, {"one", "D"} };
            String[] columnNames = {"Number", "Letter"};
            RefreshTableModel model = new RefreshTableModel(data, columnNames);
            JTable table = new JTable(model);
            table.getColumnModel().getColumn(0).setPreferredWidth(100);
            table.getColumnModel().getColumn(1).setPreferredWidth(200);
            JScrollPane scrollPane = new JScrollPane( table );
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            frame.getContentPane().add( scrollPane );
            frame.pack();
            frame.setVisible(true);
            try { Thread.sleep(3000); }
            catch (InterruptedException e) {}
            Object[][] refresh = { {"five", "E"}, {"six", "F"} };
            model.refreshDataVector( refresh );
    }

  • How to force update jtable display

    I am trying to add some filtering funtionality to my swing application that uses a JTable. What I do is to filter the JTable's datamodel, and call repaint() on the jtable and JPanel, and do jframe.pack(); Sometimes it works, sometimes it doesn't. I check the jtable model, and it is being updated properly. I guess it is a GUI update problem. Is there a better way to force the whole app's GUI to be updated?
    //update tableModel
    //repaint() jtable;
    //repaint() jpanel;
    jf.pack();

    A couple questions
    1. Did you write your own table model? Not calling fireTableDataChanged() can cause problems in this case.
    2. Do you update the table from a thread? You might need to put the updates on the event thread (SwingUtilities.invokeNoow() or invokeLater()) or manually call fireTableDataChanged() (I'm not sure if this needs to happen on the event thread)

  • Updating a Base Table through a View having UNPIVOT function.

    Hi,
    I have a requirement of updating a Base Table through a View.
    This View has the query using a UNPIVOT function for displaying the columns of the Base tables in rows.
    I need to update/insert into/delete the Base Table by accessing the View (The user doesn't have an access to the Base Table, hence the DML's on the View).
    Following is the table I've created:-
    CREATE TABLE PERSON_DETAILS
      PID            VARCHAR2(10 BYTE),
      FIRSTNAME      VARCHAR2(1000 BYTE),
      LASTNAME       VARCHAR2(1000 BYTE),
      PHONENUMBER    VARCHAR2(1000 BYTE),
      ADDRESS1       VARCHAR2(1000 BYTE),
      ADDRESS2       VARCHAR2(1000 BYTE),
      COUNTRY_CODE   VARCHAR2(1000 BYTE),
      LANGUAGE_CODE  VARCHAR2(1000 BYTE),
      EMAIL          VARCHAR2(1000 BYTE)
    )The sample values are inserted in this table through the below script:-
    insert into person_details values ('1','XYZ','ABC','1234567890','India','Asia','IN','EN','[email protected]');
    insert into person_details values ('2','XYZ2','ABC2','1234567890','India','Asia','IN','EN','[email protected]');The code for the view is as below:-
    CREATE OR REPLACE FORCE VIEW PERSON_DETAILS_VIEW
       PID,
       CD_NAME,
       CD_VALUE
    AS
       SELECT "PID", "CD_NAME", "CD_VALUE"
         FROM person_details UNPIVOT INCLUDE NULLS (cd_value
                             FOR cd_name
                             IN  (firstname AS 'First Name',
                                 lastname AS 'Last Name',
                                 phonenumber AS 'Phonenumber',
                                 address1 AS 'address1',
                                 address2 AS 'address2',
                                 country_code AS 'Country Code',
                                 language_code AS 'Language Code',
                                 email AS 'Email') );Below are the values from the view:-
    PID CD_NAME         CD_VALUE
    1    First Name       XYZ
    1    Last Name       ABC
    1    Phonenumber  1234567890
    1    address1         India
    1    address2         Asia
    1    Country Code   IN
    1    Language Code EN
    1    Email               [email protected]
    2    First Name       XYZ2
    2    Last Name       ABC2
    2    Phonenumber  1234567890
    2    address1         India
    2    address2         Asia 
    2    Country Code   IN
    2    Language Code EN
    2    Email               [email protected] user would fire some statement like below:-
    update person_details_view
    set cd_value = 'US' where CD_NAME = 'IN'The above statement should update the base table PERSON_DETAILS.
    I understand I can write an INSTEAD OF trigger but I do not know what logic to write in the trigger so that the requirement gets fulfilled.
    My Oracle Version
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0    Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionAny help would be highly appreciated.
    Thank You,
    Ankit Khare.
    Edited by: Ankit_Khare84 on Jun 28, 2012 2:47 PM

    it is definitively possible with an instead of trigger.
    for Example:
    create or replace
    TRIGGER ioft_person
    INSTEAD OF UPDATE
    ON person_details_view
    FOR EACH ROW
    declare
    firstname1  person_details.firstname%type;
    BEGIN
                  SELECT firstname_new into firstname1
                  FROM   (SELECT pid, cd_name, cd_value
                          FROM  
                                  select * from person_details_view where (pid, cd_name) not in (select :new.pid, :new.cd_name from dual)
                                  union all
                                  select :new.pid, :new.cd_name, :new.cd_value from dual
                  PIVOT  ( max(cd_value) AS new FOR (cd_name) IN
                                                          ('First Name' AS firstname,
                                                            'Last Name' as lastname,
                                                            'Phonenumber' as phonenumber,
                                                            'address1' as address1,
                                                            'address2' AS address2,
                                                            'Country Code' as country_code,
                                                            'Language Code' as language_code,
                                                            'Email' as email
                  )  where pid = :old.pid;
      UPDATE person_details
      SET firstname = firstname1
      WHERE pid = :old.pid;
    END ioft_role_perm;and than run
    update person_details_view
    set cd_value = 'X|X' where cd_name = 'First Name' and pid=1The logic is: you must convert back the view through pivoting

  • Control Windows 8.1 and WS2012 R2 "Update 1" and followings through WSUS?

    Hello all,
    Is there a way of identifying and stop through WSUS the new Updates (Update 1, Update 2 and followings) released for Windows 8.1 and WS 2012 R2?: http://blogs.windows.com/bloggingwindows/2014/04/02/windows-8-1-update-important-refinements-to-the-windows-experience/
    As far as i know, the are identified as: "Update for Windows", so its impossible to know these are a set of updates similar to a "small" service pack if you don't check the KB number associated.
    Due to my environment specs, I only make available Critical and Security updates through WSUS, so clients do not install set of updates such as service packs, which will jeopardize the environment.
    These kind of updates are not classified within Updates, Update rollups or anything else, so is there a way of stopping them or at least make them more visible on WSUS (if this makes sense)?
    Thanks in advance.

    Interesting question.... and I'm seeing a whole litany of problems with the above.
    First the answer: You simply don't approve the updates. As for identifying the updates, yeah, it's done by KB number. It will take a nominal amount of effort on your part. It's also identified by a uniquely formatted title:
    Windows 8.1 Update (KB2919355)
    BUT.. since the update was originally released into theSecurity Updates classification six months ago, if you're automatically approving Security Updates, then it's already long gone and already installed.
    Second.... not installing "Update 1" is not a choice. It's a
    mandatory update. If you've not installed this update (hard to see how that could have happened), then you've not actually deployed any to those systems since June if you've blocked this update ... the cutoff date for deploying "Update 1".
    "Update 2" is not a mandatory update, and being as the cited blog is dated April, 2014, it doesn't cover that update at all. This update was released in August 2014, and is identified only as KB2975719 and has the title
    Update for Windows 8.1 (KB2975719). It was published into Critical Updates a month ago, so again, if you're automatically approving Critical Updates.. it's long gone and already installed.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • HtmlDataTable (seem to be) not updating HtmlSelectOneListBox model values

    I have a table with multiple rows of model objects in a list. One of the controls in the row is a selectone list box with its own list of selectItem objects
    On submit and back, any text controls I have in the table and also in the form are retaining their state and updating the model values
    But the selctone list box is not updating the models?
    If I follow the phase events I see the update model phase passing through. Not sure why the data in the ui is not submitted to the model
    If I locate the ui control and ask its selected value I see the changed value. But this is not communicated to the the model.
    Is there a known issue with a data table and select drop downs, especially for keeping the state.
    The backing bean is session scope where the data for the table is maintained as a list of pojo objects. The drop down values are kept in a list of SelectItem objects
    Thanks in advance for help
    Satya

    In short, my fault.
    I have the list items bound to a list. But the I haven't bound the HtmlSelectOneList box with a value binding. I was under the impression that the selected item from this list is kept with the item as in the case of html. But in this case it is kept with the parent via its value attribute.
    Now the state is kept as the form goes back and forth.

Maybe you are looking for