Problem when getting array's elements in JSF

Using Struts/EJB/JSF.
Here is the code:
Action servlets code:
request.setAttribute("colSellers", (List<SellerDTO>) List );JSF part:
       <c:out value="${colSellers[projectForm.client].id}"/>Error message:
*[ServletException in:/html/forms/project/read.jsp] The "[]" operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer.'*
But it works when i use real integer values....like
       <c:out value="${colSellers['2'].id}"/>

Sorry, but this doesn't look like JSF, it looks like a combination of servlets, JSP EL and JSF. It will all work alot better if you choose your poison.
Put the array in a managed bean and use a JSF component like h:datagrid or t:datalist to display the elements. If that seems too restrictive, do what I did and switch to Spring MVC.

Similar Messages

  • Problems with getting array length

    I couldn't get array length in the java from the oracle.
    Here is my source.
    Can anybody answer me, I will really appriciate that.
    Thanks.
    public class Test_tb{
    public static double Test (oracle.sql.ARRAY args){
    double ret = 0;
    try {
    Double[] retArr = (Double[]) args.getArray();
    return retArr.length;
    } catch (Exception e){}
    return ret;
    }

    I've rewritten your code to include the display of any exception that might occur. Could you please run it and post any stack trace here? Thanks.
    public class Test_tb{
      public static double Test (oracle.sql.ARRAY args){
      double ret = 0;
      try {
        Double[] retArr = (Double[]) args.getArray();
        return retArr.length;
      } catch (Exception e){}
        e.printStackTrace();
        return ret;
    }

  • A problem when using a data element in BAPI

    Hi there,
    I build a function module, and want to use it as a BAPI. But when I add the function module as a method of a BAPI object, it gives me the following error: data type xxxxx cannot be used for methods.
    I guess the problem happens because of the type of data element I used for the input parameter of the function module. Thus I tried many other data elements, but I keep getting the same error. I am really out of the game. Could anyone tell me which data element I should use for the input parameter of the function module? The function module has only one input parameter, which should be a string with length less than 100.
    Thank you so much!!
    Sincerely,
    Bing

    The function module has only one input parameter, which should be a string with length less than 256. (I tried many predefined data element like RPLM_STRING, but when I tried to add the function module as a method of BAPI, the SAP always gave me the error: data type xxxxx cannot be used for methods)
    It only has one output parameter: RETURN (associated type: BAPIRETURN)
    I am really not familiar with ABAP program, let alone BAPIs. Any suggestions would be very helpful to me. I sincerely appreciate your help.
    Bing

  • Problem when getting resultset when using connection pooling in weblogic

    Hello,
    I am new to database connection pooling. I am using weblogic server, Java 1.6, MySql database. I have done connection pooling in weblogic server. The problem arise when I try to run select query I cannot fetch data in ResultSet. For insert it works fine...
    import java.io.Serializable;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    public class DatabaseToText implements Serializable {
    public DatabaseToText() {
    super();
    // TODO Auto-generated constructor stub
    public static void main(String[] args) {
    Connection conn;
    Statement stmt;
    ResultSet rs;
    String str1, str2;
    List l1 = new ArrayList();
    try {
    System.out.println("in try block");
    Properties prop = new Properties();
    prop.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    prop.put(Context.PROVIDER_URL, "t3://localhost:7001");
    System.out.println("properties are set ");
    Context ctx = new InitialContext(prop);
    System.out.println("b4 lookup(mysqljndi)");
    Object obj = ctx.lookup("mysqljndi"); // java:comp/env/CPDS
    System.out.println("afta lookup(mysqljndi)");
    DataSource ds = (DataSource) obj;
    conn = ds.getConnection();
    stmt = conn.createStatement();
    String query = "select * from logindb.userregister";
    System.out.println("query is = " + query);
    rs = stmt.executeQuery(query);
    System.out.println("size of rs is :: " + rs.getFetchSize());
    if (rs != null) {
    while (rs.next()) {
    str1 = rs.getString(0);
    str2 = rs.getString(1);
    System.out.println("username is :: " + str1 + "password is : " + str2);
    } else {
    System.out.println("no values get fetched");
    ctx.close();
    } catch (Exception e) {
    e.printStackTrace();
    OUTPUT IN CONSOLE
    in try block
    properties are set
    b4 lookup(mysqljndi)
    afta lookup(mysqljndi)
    query is = select * from logindb.userregister
    size of rs is :: 0
    java.sql.SQLException: weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception - with nested exception:
    [java.rmi.MarshalException: error marshalling return; nested exception is:
         java.io.NotSerializableException: com.mysql.jdbc.ResultSet]
         at weblogic.jdbc.rmi.SerialResultSet.next(SerialResultSet.java:89)
         at DatabaseToText.main(DatabaseToText.java:69)
    Record is getting inserted but when i use select query i cannot get the output...
    Regards,

    This problem is solved in JDBC section of this forum

  • Problem when getting the choice clicked by the user on a confirmation dialo

    Hi
    I want to prompt a confirmation Dialog, before deleting from a table,
    with yes,no,cancel options.
    Then I created 3 event handlers
    1.EmpRemove-parameter is 'cosid'
      code:
         public void EmpRemove(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String consid )
               try
                  int n=stmt.executeUpdate("delete SaConsultantMaster where ConsultantId='"consid"'");
              wdThis.showDialog("The Details of the consultant  Are removed !!!");
              wdThis.EmpReset();
               catch(Exception e){}
    2.No
    public void No(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    3.Cancel
    public void Cancel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    in my Action coding:
    I wrote.
              String Message="Do u want  to Remove The Consultant "empid" ??";
              IWDControllerInfo controllerInfo = wdControllerAPI.getViewInfo().getViewController();
              com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent1=null;
              wdThis.EmpRemove(wdEvent1,empid);
              IWDConfirmationDialog dialog =wdComponentAPI.getWindowManager().createConfirmationWindow( Message, controllerInfo.findInEventHandlers("EmpRemove"), "Yes");
              dialog.addChoice(controllerInfo.findInEventHandlers("No"),"No");
              dialog.addChoice(controllerInfo.findInEventHandlers("Cancel"),"Cancel");
              dialog.open();
    but the problem is
       Before clicking the choice, itself the record is getting deleted.
       If i click yes/No/Cancel, the action in event handler empremove is executing.
    And when passing parameters to eventhandler, what should i give for 'Event' parameter?
    can anybody help me..
    Thanks in advance.
    Smitha

    Hi Smitha,
    in your action coding you call your EventHandler EmpRemove before showing the dialog:
    wdThis.EmpRemove(wdEvent1,empid);
    IWDConfirmationDialog dialog =wdComponentAPI.getWindowManager().createConfirmationWindow( Message, controllerInfo.findInEventHandlers("EmpRemove"), "Yes");
    So remove the line "wdThis.EmpRemove(wdEvent1,empid);" and let the EventHandler do his work when the user confirms the deletion. Probably you should als check whether and how your ConsultantId is transfered as parameter. Think about removing it from the EventHandler and getting the selection straight out of the table.
    HTH
    Tina

  • IPhoto 6 Problem when editing using Photoshop Elements 3.0

    Please can someone help. If I edit a photo in photoshop elements 3.0 from iPhoto and then click the save button I get an option box that requires the quality and save settings. I've selected the best quality but I then have a choice of saving in base standard, base optimised or progressive. If I choose any of these options, when I go back into iPhoto the skin tones etc. have changed (they have a more reddish look about them)on that picture. Please can someone advise me how to save without it altering the colour of my photos. Editing in iPhoto doesn't effect the colour at all.

    Helloson:
    Welcome to the Apple Discussions. It's not that setting (I use Base Standard) but the fact that PE3 may be adding a color profile to the file that is different to what was there originally. Go to the Photoshop Elements menu and select Color Settings... option. There you can set it to have "No color management". (I'm running PE2 so the menu selections may be different than PE3). Then see if that will make a difference.
    Do you Twango?

  • Problem when getting from truststore

    Hi,
    I have a problem that when using SSL and getting trusted cert from truststore. When using System.setProperty("javax.net.debug", "all");, although the cert is not in valid date, I can get see that the cert is added like following when using jdk1.4.2_04 or later
    init truststore
    adding as trusted cert:
    Subject: ...........
    However, the exception "javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found" exists when using jdk1.4.2_03, and I can see that after init truststore, no cert is added.
    Actually, it does not affect the application, but just want to know that whether jdk1.4.2_03 or before version does not get the expired cert? jdk1.4.2_04 or later will get it?
    Thank you.

    As long as I know you cannot retrieve the pairs key/value in the usual way from a multipart-data form.
    This post is about it:
    http://forum.java.sun.com/thread.jspa?threadID=258829&messageID=971787

  • Problem when getting attribute value.. pls respnd

    Hi friends,
    I have a table with one field drop down. I created a node and subnode(for dropdown, and assinged a supplyfunction), and binded the table.
    When WDA loads, the data is populating correctly.
    When i click ADD new ROW, i am reading the current(row of table) values and storing in a table.
    to read dropdown, im using the below code:
    node_serv_prod = wd_context->get_child_node( name = wd_this->wdctx_serv_prod ).(main node)
      node_prod = node_serv_prod->get_child_node( name = wd_this->wdctx_prod ).(subnode).
      node_prod->get_static_attributes(
      EXPORTING
        index  = prev_line
        IMPORTING
          static_attributes = stru_prod )
    WHen the control goes to get_static_attribute, and when i hit F5 in debuggin, it is going to supplyfunction of subnode dropdown. which i dont want. because it is not giving the current row's value of drop down.
    Basically i want to read the current row's drop down value, when i click add new row button.
    Kindly pls tell me how can i do this.
    pls respnd.
    thanks in advance.. friends
    Niraja.

    Hi Niraja,
    Am not clear as to why you have created a subnode just for populating some values for your dropdown. You could have just created a normal attribute under the same node which you are binding to your table. You could have then typed this attribute with a domain having your desired values as its fixed values or else you could have coded within the WDDOINIT method like something shown below:
    data: lr_node_info type ref to if_wd_context_node_info,
            wa_value_set type wdr_context_attr_value,
            lt_value_set type table of wdr_context_attr_value.
      lr_node = wd_context->get_child_node( name = 'NODE' ).
      lr_node_info = lr_node->get_node_info( ).
      wa_value_set-value = '1'.
      wa_value_set-text  = 'One'.
      insert wa_value_set into table lt_value_set.
      wa_value_set-value = '2'.
      wa_value_set-text  = 'Two'.
      insert wa_value_set into table lt_value_set.
      wa_value_set-value = '3'.
      wa_value_set-text  = 'Three'.
      insert wa_value_set into table lt_value_set.
      lr_node_info->set_attribute_value_set( name      = 'TEMP'
                                             value_set = lt_value_set ).
    Your control does rightly enter into the supply function. When you are trying to add a new row you are basically trying to add a new blank entry to your internal table which is bound to your table. Now for this dropdown you have bound it to a subnode & this node has a supply function attached to it. You should keep it in mind that the supply function does get automatically triggered when:
    1) The node collection is initial.
    2) The lead selection in the parent node collection is changed.
    3) The node collection is invalidated programmatically.
    If you had used the approach of binding your dropdowns to an attribute created directly under the same node which you are using to bind to your table then even any newly added rows would automatically get the set of values populated inside them.
    Regards,
    Uday

  • Problem of getting user defined element

    Hello collegues !
    I have following problem
    I need to check, if my element was creanted on form or not
    For this i do following :
    if(oOrderForm.Items.Item("myItem")!=null)
    but this give me an exception
    are there another ways to check, if element exists or was not created yet ?
    Best regards

    there are two ways:
    1. clear way
    dim oitem as sapbouicom.item
    for each oitem in oOrderForm.Items
    ..check the item id
    next
    or
    2. quick way
    try
    dim oitem as sapbouicom.item
    oitem = oOrderForm.Items.Item("myItem")
    catch ex as exception
    ... doesnt exists
    end try

  • Problem when getting the process of execution of JAVAWS on PC

    Hello,
    I give here a part of my code:
    boolean stillrunning = true;
    Process p =null;
    while (stillrunning)
    try
         p=Runtime.getRuntime().exec(javawsPath + "javaws " + portalURL_);
    catch (Exception ext)
    printException(ext);
    try{
         int g = p.exitValue();
    stillrunning = false;
         catch(IllegalThreadStateException ex)
              printException(ex);
    The process of javaws is running normally on my Pc (Win Xp), but I have always stillrunning to false, it seems that the process p is killed but the javaws is still running.
    Can you help me? how can I get the Process p?
    Best regards

    Hello,
    Ok , I put the part that causes a problem to me :
    ============================
    Process p = null;
    boolean stillrunning= true;
    try{
    p=Runtime.getRuntime().exec(javawsPath + "javaws " + portalURL_);
    catch (Exception ext)
    printException(ext);
    try{
    int g = p.exitValue();
    stillrunning = false;
    catch(IllegalThreadStateException ex)
    printException(ex);
    ==========================
    The value of "stillrunning" is always "false", the process p is killed, however the application "javaws" is running.
    The value of exit is 0,
    Is it a normal behaviour?
    My purpose is to get the id of the process of javaws that I have launched, have you any idea how to get it.
    Thank you

  • Problem when getting the new iphone software iOS4

    I did the download to get the software but during the download i had a call ... didnt seem to disturb the download.. it then said it was backing up (syncing)... and then it would say "cancelling back up" n stop... ive tried to do it again .. many times and ive even turned both my laptop and my iphone off n retried it. but it goes straight to "backing up" but it cancells again! any help?!

    I also had trouble with updating to OS4 through iTunes update. What I did to get around it is this:
    1. Set iPhone to airplane mode and wifi off
    2. Open iTunes and connect iPhone
    3. If update message comes up - cancel (do not download and do not install)
    4. Create a backup (via sync and backup)
    5. While that is working, go to this site and download the 3GS OS4 firmware to your desktop.
    http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7437. 20100621.5urG8/iPhone2,14.0_8A293Restore.ipsw
    6. When 4 and 5 are complete, disconnect iPhone and reconnect it
    7. At the iPhone summary page, "shift + click" restore and select the firmware from the desktop.
    8. After upgrading the firmware to OS4, iTunes should recognize that the device has already been associated and offer to restore the most recent backup.

  • JTable sorting - problem when adding elements (complete code inside)

    I�m writing this email with reference to a recent posting here but this time with the code example. (I apologize for the duplicated posting � this time it will be with the code)
    Problem: when adding more elements to the JTable (sorted) the exception: ArrayIndexOutOfBoundsException is thrown.
    Example: If the elements in the table are 10 and then the user requests for 8 � the table will produce the correct result. However, if the user will ask for 11 items (>10) the exception will be thrown.
    The program: The program below (compiles and running). A JTable is constructed with 3 items, when you click the button - the return result should be 4 items - this will generate the error, WHY?
    I would highly appreciate your thoughts why this is happening and most importantly � how to fix it.
    Thanks a lot
    3 files:
    (1) TableSorterDemo
    (2) Traveler
    (3)TableSorter
    //TableSorterDemo:
    package sorter;
    import javax.swing.DefaultListModel;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    * TableSorterDemo is like TableDemo, except that it
    * inserts a custom model -- a sorter -- between the table
    * and its data model.  It also has column tool tips.
    public class TableSorterDemo implements ActionListener
         private JPanel superPanel;
         private JButton clickMe = new JButton("click me to get diff data");
         private boolean DEBUG = false;
         private DefaultListModel defaultListModel;
         private JTable table;
        public TableSorterDemo()
             superPanel = new JPanel(new BorderLayout());
             defaultListModel = new DefaultListModel();
             init1();
            TableSorter sorter = new TableSorter(new MyTableModel(defaultListModel)); //ADDED THIS     
            table = new JTable(sorter);             //NEW
            sorter.setTableHeader(table.getTableHeader()); //ADDED THIS
            table.setPreferredScrollableViewportSize(new Dimension(500, 70));
            //Set up tool tips for column headers.
            table.getTableHeader().setToolTipText(
                    "Click to specify sorting; Control-Click to specify secondary sorting");
            //Create the scroll pane and add the table to it.
            JScrollPane scrollPane = new JScrollPane(table);
            //Add the scroll pane to this panel.
            superPanel.add("Center", scrollPane);
            superPanel.add("South",clickMe);
            clickMe.addActionListener(this);              
        public JPanel getPanel()
             return superPanel;
        public void init1()
             //in real life this will be done from the db
             Traveler a = new Traveler();
             Traveler b = new Traveler();
             Traveler c = new Traveler();
             a.setFirstName("Elvis");
             a.setLastName("Presley");
             a.setSprot("Ping Pong");
             a.setNumYears(3);
             a.setVegetarian(true);
             b.setFirstName("Elton");
             b.setLastName("John");
             b.setSprot("Soccer");
             b.setNumYears(2);
             b.setVegetarian(true);
             c.setFirstName("shaquille");
             c.setLastName("oneil");
             c.setSprot("Golf");
             c.setNumYears(22);
             c.setVegetarian(true);
             defaultListModel.addElement(a);
             defaultListModel.addElement(b);
             defaultListModel.addElement(c);
        public void init2()
             //in real life this will be done from the db
             Traveler d = new Traveler();
             Traveler e = new Traveler();
             Traveler f = new Traveler();
             Traveler g = new Traveler();
             d.setFirstName("John");
             d.setLastName("Smith");
             d.setSprot("Tennis");
             d.setNumYears(32);
             d.setVegetarian(true);
             e.setFirstName("Ron");
             e.setLastName("Cohen");
             e.setSprot("Baseball");
             e.setNumYears(12);
             e.setVegetarian(true);
             f.setFirstName("Donald");
             f.setLastName("Mac Novice");
             f.setSprot("Vallyball");
             f.setNumYears(1);
             f.setVegetarian(true);
             g.setFirstName("Eithan");
             g.setLastName("Superstar");
             g.setSprot("Vallyball");
             g.setNumYears(21);
             g.setVegetarian(true);
             defaultListModel.addElement(d);
             defaultListModel.addElement(e);
             defaultListModel.addElement(f);
             defaultListModel.addElement(g);            
        class MyTableModel extends AbstractTableModel
             private DefaultListModel myModel;
             public MyTableModel(DefaultListModel m)
                  myModel=m;
            private String[] columnNames = {"First Name",
                                            "Last Name",
                                            "Sport",
                                            "# of Years",
                                            "Vegetarian"};
            public int getColumnCount()
                return columnNames.length;
            public int getRowCount()
                return myModel.size();
            public String getColumnName(int column)
                 return getNames()[column];             
             public String[] getNames()
                  String[] names = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};
                  return names;
            public Object getValueAt(int row, int col)
                 return distributeObjectsInTable(row, col, (Traveler) myModel.elementAt(row));
            public Object distributeObjectsInTable(int row, int col, Traveler tr)
               switch(col)
                         case 0:
                              return tr.getFirstName();
                         case 1:
                           return tr.getLastName();
                      case 2:
                           return tr.getSprot();
                      case 3:
                           return new Integer(tr.getNumYears());
                      case 4:
                           return new Boolean (tr.isVegetarian());
                     default:
                         return "Error";
            public Class getColumnClass(int c)
                return getValueAt(0, c).getClass();
        private static void createAndShowGUI()
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("TableSorterDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            TableSorterDemo newContentPane = new TableSorterDemo();
            newContentPane.getPanel().setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane.getPanel());
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args)
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable()                   
                public void run()
                    createAndShowGUI();
         public void actionPerformed(ActionEvent ae)
              if (ae.getSource()==clickMe)
                   defaultListModel.removeAllElements();
                   init2(); //if the size of the model was less than 2 items - the result will be ok.
                              //in other words, if you commens the last 2 rows of this method (addElement(f) & g)
                             // the result will be fine.
                   table.updateUI();          
    }//(2) Traveler
    package sorter;
    public class Traveler
         private String firstName;
         private String lastName;
         private String sprot;
         private int numYears;
         private boolean vegetarian;
         public String getFirstName()
              return firstName;
         public String getLastName()
              return lastName;
         public int getNumYears()
              return numYears;
         public String getSprot()
              return sprot;
         public boolean isVegetarian()
              return vegetarian;
         public void setFirstName(String firstName)
              this.firstName = firstName;
         public void setLastName(String lastName)
              this.lastName = lastName;
         public void setNumYears(int numYears)
              this.numYears = numYears;
         public void setSprot(String sprot)
              this.sprot = sprot;
         public void setVegetarian(boolean vegetarian)
              this.vegetarian = vegetarian;
    }//(3)TableSorter
    package sorter;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.*;
    public class TableSorter extends AbstractTableModel {
        protected TableModel tableModel;
        public static final int DESCENDING = -1;
        public static final int NOT_SORTED = 0;
        public static final int ASCENDING = 1;
        private static Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED);
        public static final Comparator COMPARABLE_COMAPRATOR = new Comparator() {
            public int compare(Object o1, Object o2) {
                return ((Comparable) o1).compareTo(o2);
        public static final Comparator LEXICAL_COMPARATOR = new Comparator() {
            public int compare(Object o1, Object o2) {
                return o1.toString().compareTo(o2.toString());
        private Row[] viewToModel;
        private int[] modelToView;
        private JTableHeader tableHeader;
        private MouseListener mouseListener;
        private TableModelListener tableModelListener;
        private Map columnComparators = new HashMap();
        private List sortingColumns = new ArrayList();
        public TableSorter() {
            this.mouseListener = new MouseHandler();
            this.tableModelListener = new TableModelHandler();
        public TableSorter(TableModel tableModel) {
            this();
            setTableModel(tableModel);
        public TableSorter(TableModel tableModel, JTableHeader tableHeader) {
            this();
            setTableHeader(tableHeader);
            setTableModel(tableModel);
        private void clearSortingState() {
            viewToModel = null;
            modelToView = null;
        public TableModel getTableModel() {
            return tableModel;
        public void setTableModel(TableModel tableModel) {
            if (this.tableModel != null) {
                this.tableModel.removeTableModelListener(tableModelListener);
            this.tableModel = tableModel;
            if (this.tableModel != null) {
                this.tableModel.addTableModelListener(tableModelListener);
            clearSortingState();
            fireTableStructureChanged();
        public JTableHeader getTableHeader() {
            return tableHeader;
        public void setTableHeader(JTableHeader tableHeader) {
            if (this.tableHeader != null) {
                this.tableHeader.removeMouseListener(mouseListener);
                TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
                if (defaultRenderer instanceof SortableHeaderRenderer) {
                    this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
            this.tableHeader = tableHeader;
            if (this.tableHeader != null) {
                this.tableHeader.addMouseListener(mouseListener);
                this.tableHeader.setDefaultRenderer(
                        new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer()));
        public boolean isSorting() {
            return sortingColumns.size() != 0;
        private Directive getDirective(int column) {
            for (int i = 0; i < sortingColumns.size(); i++) {
                Directive directive = (Directive)sortingColumns.get(i);
                if (directive.column == column) {
                    return directive;
            return EMPTY_DIRECTIVE;
        public int getSortingStatus(int column) {
            return getDirective(column).direction;
        private void sortingStatusChanged() {
            clearSortingState();
            fireTableDataChanged();
            if (tableHeader != null) {
                tableHeader.repaint();
        public void setSortingStatus(int column, int status) {
            Directive directive = getDirective(column);
            if (directive != EMPTY_DIRECTIVE) {
                sortingColumns.remove(directive);
            if (status != NOT_SORTED) {
                sortingColumns.add(new Directive(column, status));
            sortingStatusChanged();
        protected Icon getHeaderRendererIcon(int column, int size) {
            Directive directive = getDirective(column);
            if (directive == EMPTY_DIRECTIVE) {
                return null;
            return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive));
        private void cancelSorting() {
            sortingColumns.clear();
            sortingStatusChanged();
        public void setColumnComparator(Class type, Comparator comparator) {
            if (comparator == null) {
                columnComparators.remove(type);
            } else {
                columnComparators.put(type, comparator);
        protected Comparator getComparator(int column) {
            Class columnType = tableModel.getColumnClass(column);
            Comparator comparator = (Comparator) columnComparators.get(columnType);
            if (comparator != null) {
                return comparator;
            if (Comparable.class.isAssignableFrom(columnType)) {
                return COMPARABLE_COMAPRATOR;
            return LEXICAL_COMPARATOR;
        private Row[] getViewToModel() {
            if (viewToModel == null) {
                int tableModelRowCount = tableModel.getRowCount();
                viewToModel = new Row[tableModelRowCount];
                for (int row = 0; row < tableModelRowCount; row++) {
                    viewToModel[row] = new Row(row);
                if (isSorting()) {
                    Arrays.sort(viewToModel);
            return viewToModel;
        public int modelIndex(int viewIndex)
            return getViewToModel()[viewIndex].modelIndex;
        private int[] getModelToView()
            if (modelToView == null) {
                int n = getViewToModel().length;
                modelToView = new int[n];
                for (int i = 0; i < n; i++) {
                    modelToView[modelIndex(i)] = i;
            return modelToView;
        // TableModel interface methods
        public int getRowCount() {
            return (tableModel == null) ? 0 : tableModel.getRowCount();
        public int getColumnCount() {
            return (tableModel == null) ? 0 : tableModel.getColumnCount();
        public String getColumnName(int column) {
            return tableModel.getColumnName(column);
        public Class getColumnClass(int column) {
            return tableModel.getColumnClass(column);
        public boolean isCellEditable(int row, int column) {
            return tableModel.isCellEditable(modelIndex(row), column);
        public Object getValueAt(int row, int column) {
            return tableModel.getValueAt(modelIndex(row), column);
        public void setValueAt(Object aValue, int row, int column) {
            tableModel.setValueAt(aValue, modelIndex(row), column);
        // Helper classes
        private class Row implements Comparable {
            private int modelIndex;
            public Row(int index) {
                this.modelIndex = index;
            public int compareTo(Object o) {
                int row1 = modelIndex;
                int row2 = ((Row) o).modelIndex;
                for (Iterator it = sortingColumns.iterator(); it.hasNext();) {
                    Directive directive = (Directive) it.next();
                    int column = directive.column;
                    Object o1 = tableModel.getValueAt(row1, column);
                    Object o2 = tableModel.getValueAt(row2, column);
                    int comparison = 0;
                    // Define null less than everything, except null.
                    if (o1 == null && o2 == null) {
                        comparison = 0;
                    } else if (o1 == null) {
                        comparison = -1;
                    } else if (o2 == null) {
                        comparison = 1;
                    } else {
                        comparison = getComparator(column).compare(o1, o2);
                    if (comparison != 0) {
                        return directive.direction == DESCENDING ? -comparison : comparison;
                return 0;
        private class TableModelHandler implements TableModelListener {
            public void tableChanged(TableModelEvent e) {
                // If we're not sorting by anything, just pass the event along.            
                if (!isSorting()) {
                    clearSortingState();
                    fireTableChanged(e);
                    return;
                // If the table structure has changed, cancel the sorting; the            
                // sorting columns may have been either moved or deleted from            
                // the model.
                if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
                    cancelSorting();
                    fireTableChanged(e);
                    return;
                // We can map a cell event through to the view without widening            
                // when the following conditions apply:
                // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
                // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
                // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
                // d) a reverse lookup will not trigger a sort (modelToView != null)
                // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
                // The last check, for (modelToView != null) is to see if modelToView
                // is already allocated. If we don't do this check; sorting can become
                // a performance bottleneck for applications where cells 
                // change rapidly in different parts of the table. If cells
                // change alternately in the sorting column and then outside of            
                // it this class can end up re-sorting on alternate cell updates -
                // which can be a performance problem for large tables. The last
                // clause avoids this problem.
                int column = e.getColumn();
                if (e.getFirstRow() == e.getLastRow()
                        && column != TableModelEvent.ALL_COLUMNS
                        && getSortingStatus(column) == NOT_SORTED
                        && modelToView != null) {
                    int viewIndex = getModelToView()[e.getFirstRow()];
                    fireTableChanged(new TableModelEvent(TableSorter.this,
                                                         viewIndex, viewIndex,
                                                         column, e.getType()));
                    return;
                // Something has happened to the data that may have invalidated the row order.
                clearSortingState();
                fireTableDataChanged();
                return;
        private class MouseHandler extends MouseAdapter {
            public void mouseClicked(MouseEvent e) {
                JTableHeader h = (JTableHeader) e.getSource();
                TableColumnModel columnModel = h.getColumnModel();
                int viewColumn = columnModel.getColumnIndexAtX(e.getX());
                int column = columnModel.getColumn(viewColumn).getModelIndex();
                if (column != -1) {
                    int status = getSortingStatus(column);
                    if (!e.isControlDown()) {
                        cancelSorting();
                    // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                    // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                    status = status + (e.isShiftDown() ? -1 : 1);
                    status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
                    setSortingStatus(column, status);
        private static class Arrow implements Icon {
            private boolean descending;
            private int size;
            private int priority;
            public Arrow(boolean descending, int size, int priority) {
                this.descending = descending;
                this.size = size;
                this.priority = priority;
            public void paintIcon(Component c, Graphics g, int x, int y) {
                Color color = c == null ? Color.GRAY : c.getBackground();            
                // In a compound sort, make each succesive triangle 20%
                // smaller than the previous one.
                int dx = (int)(size/2*Math.pow(0.8, priority));
                int dy = descending ? dx : -dx;
                // Align icon (roughly) with font baseline.
                y = y + 5*size/6 + (descending ? -dy : 0);
                int shift = descending ? 1 : -1;
                g.translate(x, y);
                // Right diagonal.
                g.setColor(color.darker());
                g.drawLine(dx / 2, dy, 0, 0);
                g.drawLine(dx / 2, dy + shift, 0, shift);
                // Left diagonal.
                g.setColor(color.brighter());
                g.drawLine(dx / 2, dy, dx, 0);
                g.drawLine(dx / 2, dy + shift, dx, shift);
                // Horizontal line.
                if (descending) {
                    g.setColor(color.darker().darker());
                } else {
                    g.setColor(color.brighter().brighter());
                g.drawLine(dx, 0, 0, 0);
                g.setColor(color);
                g.translate(-x, -y);
            public int getIconWidth() {
                return size;
            public int getIconHeight() {
                return size;
        private class SortableHeaderRenderer implements TableCellRenderer {
            private TableCellRenderer tableCellRenderer;
            public SortableHeaderRenderer(TableCellRenderer tableCellRenderer) {
                this.tableCellRenderer = tableCellRenderer;
            public Component getTableCellRendererComponent(JTable table,
                                                           Object value,
                                                           boolean isSelected,
                                                           boolean hasFocus,
                                                           int row,
                                                           int column) {
                Component c = tableCellRenderer.getTableCellRendererComponent(table,
                        value, isSelected, hasFocus, row, column);
                if (c instanceof JLabel) {
                    JLabel l = (JLabel) c;
                    l.setHorizontalTextPosition(JLabel.LEFT);
                    int modelColumn = table.convertColumnIndexToModel(column);
                    l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
                return c;
        private static class Directive {
            private int column;
            private int direction;
            public Directive(int column, int direction) {
                this.column = column;
                this.direction = direction;
    }

    The table listens to the TableModel for changes. Changing the table by adding/removing
    rows or columns has no affect on its table model. If you make changes to the table model
    the table will be notified by its TableModelListener and change its view. So tell
    MyTableModel about the change of data:
    public class TableSorterDemo implements ActionListener
        MyTableModel tableModel;
        public TableSorterDemo()
            defaultListModel = new DefaultListModel();
            init1();
            tableModel = new MyTableModel(defaultListModel);
            TableSorter sorter = new TableSorter(tableModel);
        public void actionPerformed(ActionEvent ae)
            if (ae.getSource()==clickMe)
                defaultListModel.removeAllElements();
                init2();
                tableModel.fireTableStructureChanged();
    }

  • Photoshop/Premiere Elements 11 Freeze When Getting Media

    Hello Everyone,
    Whenever I start Elements Organiser, there is an on-screen message that there are files ready to import and that the Organiser will now import these files into the Catalog. Then a "Getting Media" box displays and, at some point, say 56%, the "racing cursor" appears and the programme does nothing more. It just freezes and eventually there is a Windows message stating that the programme is not responding. This happens in Elements/Premiere 11. I reinstalled Elements 6 and the file importing works quickly and without problem in that version of Elements.
    This is a new, custom-built PC, running Windows 7 Home Premium 64-bit. 16 Gb memory. Adobe programmes were installed for 64-bit OS exactly as directed in Adobe instructions. All hardware drivers are up to date. No other problems with any other software, just Adobe's Elements 11 bundle !
    Suggestions ? Solutions ? Other, older Adobe programmes work just fine. When will Adobe correct these programming bugs ? Will they ever ?
    Thank you in advance for any helpful advice.
    Sincerely,
    Rafi C.

    Hello,
    Well, actually, I think on my machine it is 'services.msc'. Yes, I found it and it doesn't help with the problem of the 'getting media' process freezing. I have gone so far as to remove ALL media from this machine, and STILL the programme displays images as it tries to import files that aren't there. This problem is ALSO duplicated on our old WIN7 32-bit machine and also on a neighbour's WIN7 32-bit machine, all with different copies of Elements 11.
    At this point, my question is quite specific: where is PSE11 finding media files that are no longer there ?
    I am just happy that our old PSE6 works like a charm--no problems there. Too bad those programmers are probably long retired ! What I'm going to do now is basically write off the Organiser as a waste of time and money. I'm putting shortcuts on the Desktop to the PSE andPRE 11 editors. And will install Picasa and use that to sort our media files.
    But, in the meantime, again, where is Origaniser finding downloaded media files that have been removed ? Is there a file within PSE11 Organiser that we can delete ?
    Many thanks for your help.
    Rafi C.

  • Why does Elements 12 crash as soon as I open Type tool?  Get message "An unexpected and unrecoverable problem has occurred.  Photoshop Elements will now exit.  Using Mac

    Why does Elements 12 crash as soon as I open Type tool?  Get message "An unexpected and unrecoverable problem has occurred.  Photoshop Elements will now exit."  Using Mac.  No imported fonts

    Thank you, Barbara.  All fonts seemed fine, no empty or duplicates.  When I went back to Elements and tried again, it did not crash!  After months of not being able to use type tool,,, not sure why it worked, but it did.  Thanks again!  I appreciate the time you took to answer my question.

  • When I start PS Elements 11 editor, I get this message: "This program can't start because MSVCRT10.d

    When I start PS Elements 11 editor, I get this message: "This program can't start because MSVCRT10.dll is missing from your computer. Try reinstalling this program to fix this problem."
    When I try to dismiss the error dialogue box, the message reappears immediately and the program does not load. After dismissing the dialogue 8 or 10 or 12 times, the editor finally loads and everything works okay.
    How may I solve this frustrating problem? I've already uninstalled and reinstalled the program and that hasn't solved the issue. If I need to add a .dll file to my machine, where do I locate it and where do I place it on my computer?
    Thanks
    William Driver

    Using Holmesian deductive skills and Spadian investigative techniques, I discovered that the problem lay in a third party filter application. I determined that since the program gave me the error message when PSE 11 began its scan for filter plugins, then the problem might lie there. I removed the filter plugins from the program's 'Plugins' directory to a another folder and added them back one by one until I got the error message. Sure enough, I eventually located the faulty plugins and removed them. Now PSE 11 loads without a problem.
    Thanks for your help.

Maybe you are looking for