Shah Devang

Greenhorn
+ Follow
since Jul 27, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shah Devang

Hi All,

Can I invoke a portlet B from portlet A, on some action from portlet A? I am using JBoss Portal Server.

Thanks In Advance
Devang Shah
16 years ago
To add, I am using JBoss Portals.
16 years ago
Hi All,

I have a search portlet. There is one search portlet, and one or more results portlets. Each of these portlets are deployed as different war files. What I need is, if user enters some search string, I need to pass the search string to other portlets. Is there any way to achieve this? Since portlets are part of different applications, using APPLICATION of portlet session will not help. I need to have different applications for each portlet since they are all loosely coupled. Each search result portlet will show different results. User has the freedom of selecting search result portlets as per their convenience.

Hope the requirements are clear?

Thanks In Advance
Devang Shah
16 years ago
Hi All,

I am a newbie on Struts2. Could anyone please provide links for articles, documents from where I can start with Struts2.

Thanks
Devang Shah
16 years ago
Hi All,

I am developing a Swing standalone application. I have some UI component wherein I need to fetch data from 3rd Party ITS systems, like JIRA, Bugzilla or TeamTrack.

I have following requirements -
1. User specifies the ITS type.
2. User specifies URL to the ITS server.
3. User provides the login credentials also (administrator one).

Now using this information I need to fetch the fields present on ITS and also the filters. I want a generic way to implement this.

Can anyone please help me?

Thanks
Devang Shah
17 years ago
Hi,

I have a JList which shows file data. I have provided with the search facility through which user can search in through the file. JList provides a function 'getNextMatch(String prefix, int startIndex, Position.Bias bias)' to search, however this function only searches for those words which are complete, and not substrings. What I can do is provide a similar functionality by implementing my own search function, but I am not getting how to highlight the searched word in the list.

Can anybody please help.

Thanks
Devang Shah
17 years ago
Hi,

In my applet jar, I have added the images that I want to show on the toolbar. In the init() function of the applet, I create the button and set the image, however, in the Java Console of the browser I get the following error message :

ava.lang.ExceptionInInitializerError

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Caused by: java.security.AccessControlException: access denied (java.io.FilePermission com/accurev/jira/images/first.png read)

at java.security.AccessControlContext.checkPermission(Unknown Source)

at java.security.AccessController.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkRead(Unknown Source)

at sun.awt.SunToolkit.getImageFromHash(Unknown Source)

at sun.awt.SunToolkit.getImage(Unknown Source)

at javax.swing.ImageIcon.<init>(Unknown Source)

at javax.swing.ImageIcon.<init>(Unknown Source)

at com.accurev.jira.diffview.DiffApplet.<clinit>(DiffApplet.java:28)

... 11 more


Can anyone please help me out ?
What all I need to do in order to access the images that are in the applet jar.

Thanks
Devang Shah
17 years ago
Hi,

What I am trying to show in Applet is a diff window. The diff tool gives me a swing based window ouput showing the diff of the two files. Now I want this window to be shown on the clients browser. Now since its diff, the data size can be huge. Can you please show some pointers how do I achieve this ?

Thanks
Devang Shah
17 years ago
Hi,

So can I atleast send string objects from servlet to the applet ?


Thanks
Devang Shah
17 years ago
Hi,

I have a HTML page that has some links. When I click a link, I want to display the applet and its data differs depending upon the element selected. To achieve this, I made an HTTP call to the servlet and passed it the element selected as parameter. Depending upon the element selected I create a swing object that I want to render on the applet. This object I pass to the applet and add this to the applet.

But this is not working. I am getting the following exception on the Java console :

java.io.InvalidClassException: javax.swing.JComponent; local class incompatible: stream classdesc serialVersionUID = 5896976265092562486, local class serialVersionUID = 7917968344860800289
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.accurev.HelloWorldApplet.readInputStream(HelloWorldApplet.java:78)
at com.accurev.HelloWorldApplet.sendObject(HelloWorldApplet.java:51)
at com.accurev.HelloWorldApplet.init(HelloWorldApplet.java:28)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at java.awt.Container.addImpl(Unknown Source)
at java.awt.Container.add(Unknown Source)
at com.accurev.HelloWorldApplet.init(HelloWorldApplet.java:31)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

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

The code that I have implemented goes like this :




The DiffPanel object extends JPanel and implements Serializable.

Can anyone please help.

Thanks
Devang Shah
17 years ago
Hi,

I am developing a plugin for JIRA. When I deploy this plugin, I copy the plugin jar to the lib folder of JIRA. In the jar, I have classes HelloWorldServlet and HelloWorldApplet present in the same package. When a request come to the servlet, I put the following html code in the PrintWriter object of the servlet.

out.println("<applet code=\"com.plugin.HelloWorldApplet.class\" width=\"100\" height=\"140\"></applet>");
out.close();


On the browser, it shows 'Failed to load the applet' and in the console I get error message 'Unable to find the file'. Say the JIRA server is on one machine, X and I am accessing it from another machine, say Y.

Is there something that I am doing wrong ?

Thanks
Devang Shah
17 years ago
I am trying to implement a UI component wherein a leaf node in JTree when expanded shows a populated table. Below is the code for this, can anyone please check where am I going wrong ...

/************ TreeComponent ************/

import java.awt.Container;
import java.awt.Dimension;
import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.JScrollPane;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;

public class TreeComponent {

JPanel topPanel = null;
JFrame frame = null;
Container contentPane = null;
Dimension d = null;
private DefaultMutableTreeNode root = null, node = null, parent = null;

public TreeComponent () {

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}

frame = new JFrame("Table In Tree Component");

contentPane = frame.getContentPane();
d = frame.getToolkit().getScreenSize();

frame.setSize(700, 600);
frame.setLocation(d.width/2-frame.getWidth()/2, d.height/2-frame.getHeight()/2);

initComponent();

JFrame.setDefaultLookAndFeelDecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}

public void initComponent () {
// panel with Border Layout
topPanel = new JPanel(new BorderLayout());
JTree tree = createTreeComponent();

JScrollPane scrollPane = new JScrollPane();
scrollPane.getViewport().add(tree);
topPanel.add(scrollPane, BorderLayout.CENTER);

topPanel.setVisible(true);
contentPane.add(topPanel);
}

public JTree createTreeComponent() {
DefaultTreeModel treeModel = null;
treeModel = createTreeModel();

JTree tree = new JTree(treeModel);
tree.setCellRenderer(new CustomTreeCellRenderer());
tree.setCellEditor(new CustomTreeCellEditor(tree));
tree.setEditable(false);
return tree;
}

public DefaultTreeModel createTreeModel() {
root = new DefaultMutableTreeNode("Tree Top");
parent = root;

node = new DefaultMutableTreeNode("Table A");
node.add(new DefaultMutableTreeNode(new TableComponent()));
parent.add(node);

node = new DefaultMutableTreeNode("Table B");
parent.add(node);

return new DefaultTreeModel(root);
}

public static void main (String args[]) {
new TreeComponent();
}
}

/************ TableComponent ************/


import java.awt.GridLayout;
import java.awt.FlowLayout;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Component;

import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIManager;

import javax.swing.table.TableColumn;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;


public class TableComponent extends JPanel {
private JTable table = null;
private JScrollPane scrollPane = null;

public TableComponent() {
super(new GridLayout(1,1));
table = new JTable(new CustomTableModel());
initColumnSizes();
table.setPreferredScrollableViewportSize(new Dimension(150, 100));
scrollPane = new JScrollPane(table);
add(scrollPane);
}

public void initColumnSizes() {
TableColumn column = null;
Component component = null;
int headerWidth = 0;
int cellWidth = 0;
JTableHeader tableHeader = null;

CustomTableModel tableModel = (CustomTableModel)table.getModel();

Object longValues[] = tableModel.longValues;

tableHeader = table.getTableHeader();
TableCellRenderer headerRenderer = tableHeader.getDefaultRenderer();

for( int i=0; i<5; i++ ) {
column = table.getColumnModel().getColumn(i);
component = headerRenderer.getTableCellRendererComponent(null, column.getHeaderValue(), false, false, 0, 0);
headerWidth = component.getPreferredSize().width;

System.out.println(table.getDefaultRenderer(tableModel.getColumnClass(i)).getTableCellRendererComponent(table, longValues, false, false, 0, i));
component = table.getDefaultRenderer(tableModel.getColumnClass(i)).getTableCellRendererComponent(table, longValues, false, false, 0, i);
cellWidth = component.getPreferredSize().width;

column.setPreferredWidth(Math.max(headerWidth, cellWidth));
}
}

public static void main(String args[]) {
JFrame frame = new JFrame();
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
frame.getContentPane().add(new TableComponent());
frame.setSize(350, 350);
JFrame.setDefaultLookAndFeelDecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

}
}

/************ CustomTableModel ************/

public class CustomTableModel extends AbstractTableModel {
private boolean DEBUG = true;
private String[] columnNames = {
"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"
};
private Object[][] data = {
{ "Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false) },
{ "Alison", "Huml", "Rowing", new Integer(3), new Boolean(true) },
{ "Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false) },
{ "Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true) },
{ "Philip", "Milne", "Pool", new Integer(10), new Boolean(false) }
};

public final Object[] longValues = { "Sharon", "Campione", "None of the above", new Integer(20), Boolean.TRUE };

public int getColumnCount() {
return columnNames.length;
}

public int getRowCount() {
return data.length;
}

public Object getValueAt(int rowIndex, int columnIndex) {
return data[rowIndex][columnIndex];
}
}

/************ CustomTreeCellEditor ************/

import java.awt.Component;

import javax.swing.JTree;
import javax.swing.JScrollPane;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellEditor;
import javax.swing.tree.DefaultTreeCellRenderer;


public class CustomTreeCellEditor extends DefaultTreeCellEditor {
public CustomTreeCellEditor(JTree tree) {
super(tree, (DefaultTreeCellRenderer)null);
}

public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
if ( value instanceof DefaultMutableTreeNode ) {
DefaultMutableTreeNode node = ( DefaultMutableTreeNode ) value;
if ( node.getUserObject() instanceof TableComponent ) {
return new JScrollPane( ( TableComponent ) node.getUserObject() );
}
}
return super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
}
}


/************ CustomTreeCellRenderer ************/

import java.awt.Component;

import javax.swing.JTree;
import javax.swing.JScrollPane;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;

public class CustomTreeCellRenderer extends DefaultTreeCellRenderer {

public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
if (node.getUserObject() instanceof TableComponent) {
return new JScrollPane((TableComponent) node.getUserObject());
}
}
return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
}
}


/*****************************************/

Do let me know at the earliest.
Execute the TreeComponent class
[ July 27, 2006: Message edited by: Shah Devang ]
17 years ago