Hi Janak,

The code snippet that you have provided below did work for me in
development mode.  I am getting the following error when I launch my
application using jnlp.

java.lang.NoClassDefFoundError: com/ulcjava/base/client/UITable
at
java.lang.ClassLoader.defineClass(Ljava/lang/String;[BIILjava/security/P
rotectionDomain;)Ljava/lang/Class;(Unknown Source)      at
java.security.SecureClassLoader.defineClass(Ljava/lang/String;[BIILjava/
security/CodeSource;)Ljava/lang/Class;(SecureClassLoader.java:123)
at
weblogic.utils.classloaders.GenericClassLoader.findLocalClass(Ljava/lang
/String;)Ljava/lang/Class;(GenericClassLoader.java:480)         at
weblogic.utils.classloaders.GenericClassLoader.findClass(Ljava/lang/Stri
ng;)Ljava/lang/Class;(GenericClassLoader.java:182)      at
weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(Ljava/lang/
String;)Ljava/lang/Class;(ChangeAwareClassLoader.java:61)       at
java.lang.ClassLoader.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;(Un
known Source)   at
java.lang.ClassLoader.loadClass(Ljava/lang/String;)Ljava/lang/Class;(Unk
nown Source)    at
weblogic.utils.classloaders.GenericClassLoader.loadClass(Ljava/lang/Stri
ng;)Ljava/lang/Class;(GenericClassLoader.java:224)      at
weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(Ljava/lang/
String;)Ljava/lang/Class;(ChangeAwareClassLoader.java:41)       at
java.lang.ClassLoader.loadClassFromNative(II)Ljava/lang/Class;(Unknown
Source)         at
jrockit.vm.Classes.forName0(Ljava/lang/String;ZI)I(Unknown Source)
at
jrockit.vm.Classes.forName(Ljava/lang/String;ZLjava/lang/ClassLoader;)Lj
ava/lang/Class;(Unknown Source)         at
java.lang.Class.forName(Ljava/lang/String;I)Ljava/lang/Class;(Unknown
Source)         at
com.hp.gdic.scmas.ulc.util.model.authorized.SCMASTable.class$(Ljava/lang
/String;)Ljava/lang/Class;(Unknown Source)      at
com.hp.gdic.scmas.ulc.util.model.authorized.SCMASTable.typeString()Ljava
/lang/String;(Unknown Source)   at
com.ulcjava.base.application.ULCProxy.getRef()Lcom/ulcjava/base/shared/i
nternal/Anything;(ULCProxy.java:198)    at
com.ulcjava.base.application.ULCContainer.a(Lcom/ulcjava/base/applicatio
n/ULCComponent;Ljava/lang/Object;I)Lcom/ulcjava/base/shared/internal/Any
thing;(ULCContainer.java:48)    at
com.ulcjava.base.application.ULCContainer.a(Ljava/util/List;Ljava/util/M
ap;)Lcom/ulcjava/base/shared/internal/Anything;(ULCContainer.java:89)
at
com.ulcjava.base.application.ULCContainer.saveState(Lcom/ulcjava/base/sh
ared/internal/Anything;)V(ULCContainer.java:94)         at
com.ulcjava.base.application.ULCScrollPane.saveState(Lcom/ulcjava/base/s
hared/internal/Anything;)V(ULCScrollPane.java:13)       at
com.ulcjava.base.application.ULCProxy.getRef()Lcom/ulcjava/base/shared/i
nternal/Anything;(ULCProxy.java:119)    at
com.ulcjava.base.application.ULCContainer.a(Lcom/ulcjava/base/applicatio
n/ULCComponent;Ljava/lang/Object;I)Lcom/ulcjava/base/shared/internal/Any
thing;(ULCContainer.java:48)    at
com.ulcjava.base.application.ULCContainer.a(Ljava/util/List;Ljava/util/M
ap;)Lcom/ulcjava/base/shared/internal/Anything;(ULCContainer.java:89)
at
com.ulcjava.base.application.ULCContainer.saveState(Lcom/ulcjava/base/sh
ared/internal/Anything;)V(ULCContainer.java:94)         at
com.ulcjava.base.application.ULCBoxPane.saveState(Lcom/ulcjava/base/shar
ed/internal/Anything;)V(ULCBoxPane.java:129)    at
com.ulcjava.base.application.ULCProxy.getRef()Lcom/ulcjava/base/shared/i
nternal/Anything;(ULCProxy.java:119)    at
com.ulcjava.base.application.ULCContainer.a(Lcom/ulcjava/base/applicatio
n/ULCComponent;Ljava/lang/Object;I)Lcom/ulcjava/base/shared/internal/Any
thing;(ULCContainer.java:48)    at
com.ulcjava.base.application.ULCContainer.a(Ljava/util/List;Ljava/util/M
ap;)Lcom/ulcjava/base/shared/internal/Anything;(ULCContainer.java:89)
at
com.ulcjava.base.application.ULCContainer.saveState(Lcom/ulcjava/base/sh
ared/internal/Anything;)V(ULCContainer.java:94)         at
com.ulcjava.base.application.ULCBoxPane.saveState(Lcom/ulcjava/base/shar
ed/internal/Anything;)V(ULCBoxPane.java:129)    at
com.ulcjava.base.application.ULCProxy.getRef()Lcom/ulcjava/base/shared/i
nternal/Anything;(ULCProxy.java:119)    at
com.ulcjava.base.application.ULCContainer.a(Lcom/ulcjava/base/applicatio
n/ULCComponent;Ljava/lang/Object;I)Lcom/ulcjava/base/shared/internal/Any
thing;(ULCContainer.java:48) 

I am getting this in the typeString method;

protected String typeString() {
        return
com.hp.gdic.scmas.ulc.util.model.authorized.SCMASTable.UIExtendedTable.c
lass.getName();
}


Thanks & Regards
Prasanta 

-----Original Message-----
From: Janak Mulani [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 28, 2006 4:08 PM
To: Behera, Prasanta Kumar
Cc: [EMAIL PROTECTED] Com
Subject: RE: [ULC-developer] Is it possible to get hold of the
underlying Swing table from ULCTable?

Hi Prasanta,

First of all, you can  set header renderer on ULCTableColumn using
setHeaderRenderer(ITableCellRenderer headerRenderer). Renderers and
Editors can be set on columns on the server side.

Having said the above, I looked at your old correspondence with Marc
Hermann where in he had suggested a ULCTable extension to set a custom
header renderer that handles wrapping of header text. In his opinion
this was an easier option than implementing a renderer based on
ULCTextArea.

However there is an alternative which does not require any extension.
ULCTable uses ULCLabel as DefaultTableHeaderCellRenderer. On ULCLabel
you can set HTML text in which you can have multiple line breaks. Please
see the snippet at the end of this mail which demonstrates multiline
header and cells. Let me know if this works for you or otherwise.

If the above solution is not good for you, then you need to change your
existing code as follows:

1. In restoreState() extract the code for setting custom header renderer
into a separate method of UIExtendedTable:

  public void setCustomHeaderRenderer() {
   JWordWrapTableHeader headerRenderer = new JWordWrapTableHeader();

   for (Enumeration enumeration =
getBasicTable().getColumnModel().getColumns();
enumeration.hasMoreElements();) {
        TableColumn column = (TableColumn) enumeration.nextElement();
        column.setHeaderRenderer(headerRenderer);
    }
  }

2. call this method in restoreState() after calling
super.restoreState().

3. In ULCExtendedTable introduce a method:

   public void setCustomHeaderRenderer() {
        sendUI("setCustomHeaderRenderer");
   }

4. In UIExtendedTable override handleRequest method as follows:

        public void handleRequest(String request, Anything args) {
        if (request.equals("setCustomHeaderRenderer")) {
            setCustomHeaderRenderer();
        } else {
          super.handleRequest(request, args);
        }
    }

5. In your ULC application, invoke setCustomHeaderRenderer() after you
have invoked fireTableStructureChanged().

I hope this helps.

Thanks and regards,

Janak


>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of Behera, 
>Prasanta Kumar
>Sent: Friday, July 28, 2006 8:20 AM
>To: [EMAIL PROTECTED] Com
>Cc: [email protected]
>Subject: RE: [ULC-developer] Is it possible to get hold of the 
>underlying Swing table from ULCTable?
>
>
>Hi Janak,
>
>If you check my code snippet(given below) I am setting the renderer in 
>the column header of the underlying swing table. This I am doing in 
>order to achieve word wrapping in the column header of the table.
>In order to set renderers on the columns again immediately after 
>calling
>fireTableStructureChanged() method I need to get the renderer. So my 
>question is how do I get the renderer which is set to the column header

>of the underlying swing table?
>
>Thanks & Regards
>Prasanta
>
>-----Original Message-----
>From: Janak Mulani [mailto:[EMAIL PROTECTED]
>Sent: Thursday, July 27, 2006 7:26 PM
>To: Behera, Prasanta Kumar
>Cc: [email protected]
>Subject: RE: [ULC-developer] Is it possible to get hold of the 
>underlying Swing table from ULCTable?
>
>Hi Prasanta,
>
>First of all you should never invoke restoreState() method in your 
>code, it is invoked by ULC while managing the life cycle of the client 
>side half object.
>
>>But our project has an additional requirement. Our project has 
>>something called a field chooser utility. When a user clicks on the 
>>field chooser he gets a list of columns. The user can select any 
>>number
>
>>of columns that he would like to view and the table is refreshed with 
>>the selected columns. While refreshing the table I am using
>>fireTableStructureChanged() method. When I call
>>fireTableStructureChanged() method it is removing the effect of word 
>>wrapping in the column header. I am not very sure why it is behaving 
>>in
>
>>such a fashion.
>
>When you do fireTableStructureChanged() all columns of the table are 
>recreated if you have autoCreateColumnsFromModel set to true. This is 
>the reason why all renderers including those for headers are lost.
>
>There are two solutions:
>
>1. Set renderers on the columns again immediately after you do 
>fireTableStructureChanged().
>
>Or
>
>2. Set autoCreateColumnsFromModel to false and create and add columns 
>to the table programmatically. Add your renderers to these columns. 
>Keep this set of columns in a collection. Subsequently in your field 
>chooser utility you can selectively add or remove columns to your table

>from this collection.
>
>I hope this helps.
>
>Thanks and regards,
>
>Janak
>
>
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of Behera, 
>Prasanta Kumar
>Sent: Wednesday, July 26, 2006 7:42 AM
>To: [email protected]
>Subject: [ULC-developer] Is it possible to get hold of the underlying 
>Swing table from ULCTable?
>
>
>Hi All,
>
>Is it possible to get hold of the underlying swing table from the 
>ULCTable?
>
>In order to achieve wrapping in the column header I have done the
>following:
>Created both extended ULCTable and UITable class.
>The ULC class just overrides typeString() and the UI class 
>restoreState().
>The text area renderer component is eventually set on the underlying 
>Swing table in the restoreState() method after calling super().
>Code Snippet is as given below:
>
> protected String typeString() {
>  // works only in development mode; to be replaced by a full-qualified

>package string
>  return UIExtendedTable.class.getName();  }
>
> public static class UIExtendedTable extends UITable {  public void 
> restoreState(Anything args) {
>   super.restoreState(args);
>
>   JWordWrapTableHeader headerRenderer = new JWordWrapTableHeader();
>
>   for (Enumeration enumeration = getBasicTable().getColumnModel()
>     .getColumns(); enumeration.hasMoreElements();) {
>    TableColumn column = (TableColumn) enumeration.nextElement();
>    column.setHeaderRenderer(headerRenderer);
>   }
>  }
>
>  private static class JWordWrapTableHeader extends JTextArea 
>implements TableCellRenderer {
>   public JWordWrapTableHeader() {
>    setLineWrap(true);
>    setWrapStyleWord(true);
>    setBackground(new Color(223, 235, 252));
>    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
>   }
>
>   public Component getTableCellRendererComponent(JTable table,
>     Object value, boolean isSelected, boolean hasFocus, int row,
>     int column) {
>    setText((String) value);
>    setSize(table.getColumnModel().getColumn(column).getWidth(),
>      getPreferredSize().height);
>    return this;
>   }
>  }
> }
>
>But my project has an additional requirement. My project has something 
>called a field chooser utility. When a user clicks on the field chooser

>he gets a list of columns. The user can select any number of columns 
>that he would like to view and the table is refreshed with the selected

>columns.
>While refreshing the table I am using fireTableStructureChanged() 
>method.
>When I call fireTableStructureChanged() method it is removing the 
>effect of word wrapping in the column header. I need to set the 
>renderer again on the underlying Swing table.
>Is it possible to get hold of the underlying Swing table from ULCTable?
>If this is possible I can again set the renderer on the underlying 
>Swing table after calling fireTableStructureChanged() method? If this 
>is not possible is there a way to set the renderer again after calling
>fireTableStructureChanged() method?
>Thanks & Regards
>Prasanta

-----------------------

import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ULCBoxPane;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.table.AbstractTableModel;
import com.ulcjava.base.application.table.DefaultTableCellRenderer;
import
com.ulcjava.base.application.table.DefaultTableHeaderCellRenderer;
import com.ulcjava.base.development.DevelopmentRunner;

public class WrapCellSnippet extends AbstractApplication {
    public void start() {
        ULCTable table = new ULCTable(new AbstractTableModel() {
            public int getColumnCount() {
                return 3;
            }

            public int getRowCount() {
                return 10;
            }

            public Object getValueAt(int rowIndex, int columnIndex) {
                return "<html><b>Row:</b> " + rowIndex +
"<br><b>Column:</b>" + columnIndex + "</html>";
            }

            public String getColumnName(int column) {
                return "<html><b>Column</b><br>" + column + "</html>" ;
            }
        });

        for (int i = 0; i < table.getColumnCount(); i++) {
            table.getColumnModel().getColumn(i).setCellRenderer(new
DefaultTableCellRenderer());
            table.getColumnModel().getColumn(i).setHeaderRenderer(new
DefaultTableHeaderCellRenderer());
        }
        table.setRowHeight(2 * table.getRowHeight());

        ULCBoxPane contentPane = new ULCBoxPane(1, 0);
        contentPane.add(ULCBoxPane.BOX_EXPAND_EXPAND, new
ULCScrollPane(table));


        ULCFrame frame = new ULCFrame("WrapCellSnippet");
        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
        frame.add(contentPane);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        DevelopmentRunner.setApplicationClass(WrapCellSnippet.class);
        DevelopmentRunner.main(args);
    }
}

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to