NUMBER_OF_VERB_FRAMES

2005-09-22 21:13:40 | Weblog
JSPでJWNLを起動してやってみたら、
java.lang.NumberFormatException: For input string: "NUMBER_OF_VERB_FRAMES"というエラーメッセージが出た、
そこで、取った行動は:
JWNLResource_en.propertiesファイルをWEB-INF\classes¥にコピーしてみたら、問題解決した。
JWNLResource_en.propertiesファイルはJWNL.JARファイルを解凍したフォルダに入っているはず。
ここで分からないのは:JWNL.jarファイルのパスはちゃんとプロジェクトのクラスパスに通ってるのに、どうして手動で、JWNLResource_en.propertiesを取り出して、一番トップのクラスファルダに移動する必要があるか?

How to pass javascript variable to jsp page

2005-09-20 00:47:33 | Weblog

JavaScriptからJSPへ変数を渡す方法。

I need to pass the variables which are used in javascript to jsp page? Is it possible or not? If yes how? I can verywell do the same process in the opposite direction, that is sending variables from jsp to javascript.
 

Re: How to pass javascript variable to jsp page?
Author: mshanu   Jun 2, 2005 9:59 PM (reply 1 of 5)  
 

u can assign values to ur form fields like document.form1.field.value..i think this will work..pls try and let me know..
regards
shanu
 

Re: How to pass javascript variable to jsp page?
Author: evnafets   Jun 2, 2005 10:03 PM (reply 2 of 5)  
 

The only communication from javascript to java is via request parameters when you click a link/submit a form.

So you can set the javascript variables into form fields (input type="hidden" is popular) and submit the form.
 

Re: How to pass javascript variable to jsp page?
Author: Nilalini   Jun 6, 2005 10:19 PM (reply 3 of 5)  
 

Dear pals

I am asking this for a single .jsp file. I am putting jsp and javascript together in a file. like

var a; // javascript
a=10; //javascript


// jsp starts here in the same program
<%

int b;

//here i need to assign a to b.
%>
 

Re: How to pass javascript variable to jsp page?
Author: mshanu   Jun 6, 2005 10:32 PM (reply 4 of 5)  
 

I think u can do that..cuz java script is in the client side and scriplets supposed to run in the server side.u have to append the value in the java script to the request and get in the sriplet...
regards
shanu
 

Re: How to pass javascript variable to jsp page?
Author: Virendra   Jun 6, 2005 10:46 PM (reply 5 of 5)  
 

Dear

To pass variable value from JavaScript to JSP

to do so u have to use <form> tag.
to pass data from javascript to JSP u have to submit form and
u should get data like request.getParameter("varName");
this method will return all the data as string.

If you want script variable data in same JSP page then
u have to write form tag like <form name='form1' action='yourJspPage.jsp' >

-----------
To get JSP variables data in javaScript

it is so easy.

This is one sample example like under for your both questation.

file name : test.jsp

<@ page inport="...." %>
<%
String FirstName="";
String caption="Go";
 
FirstName = request.getParameter("firstname");
%>
<html>
<head>
<script language="javascript" >
function checkAll()
{
     if(document.form1.firstname.value=="")
     {
         alert("Invalid text");
         return false;
      }
      return true;
}
function setJSPvalueToScript()
{
      var testVar;
      testVar='<%=caption%>';
      alert(testVar);
      // here value is set when page in loaded not function is called
      // you can see  by viewing source of this file
}
</script>
</script>
</head>
<body>
<form name="form1" action="test.jsp" onSubmit="return checkAll()" >
 
<input type="text" name="firstname"  value="<%=FirstName%>" >
<input type="submit" value="<%=caption%>" >
 
<input type="button" onClick="setJSPvalueToScript()" >
</form>
</body>
</html>

 


JUNGに関して、結局使わなかったけど

2005-09-19 02:50:01 | Weblog
How to add vertex to a user-defined position
2005-09-01 01:40
hello , every one
What I want to do is very simple. I just want to add vertexs to the appointed position in graph without using Layout arigorism offered by JUNG, How can I do it , and Is there any useful methods like add(Vertex v, Positon p)? and where is it? I checked some threads about this topic , but failed to find any solution.

Thanks in advance.




By: Dhaval - dhaval04
RE: How to add vertex to a user-defined posit
2005-09-01 04:57
Hi,

I have post similar message like this before. (https://sourceforge.net/forum/forum.php?thread_id=1291001&forum_id=252062)

Anyway let me give you some hints. Layout does not need to be an algorithm. Using layout class, vertices are positioned on graph.

For your case, I would do following:

(1) Make my own vertex extending SparseVertex, say MyVertex.
(2) In MyVertex, I will put fields X, Y (x,y location of graph). You can set these fields while adding vertex to graph. Remember to set these fields before you add Layout to graph.
(3) Make my layout MyLayout extending AbstractLayout. (You can use other layout if you want. Abstract will give you bare basic stuff to go on). In this MyLayout, override the method initializeLocations() as follows:

protected void initializeLocations()
{
super.initializeLocations();
Vertex[] vertices = (Vertex[]) getVisibleVertices().toArray(new Vertex[0]);
orderVertices(vertices);

for (int i = 0; i <vertices.length; i++) Coordinates coord = getCoordinates(vertices[i]);

coord.setX( ((MyVertex) vertices[i]).getX() );
coord.setY( ((MyVertex) vertices[i]).getY() );

// Rest of stuff.
}
}

I think this way you can position vertex at desired position. One more thing. When you add vertex to graph, it will add to graph data structure. Still you need to write one layout to calculate positions of that vertex in graph drawing.

You can refer to examples and source for more information. I hope above talk will get you moving. Feel free to post questions.

Regards,
Dhaval



  By: Nobody/Anonymous - nobody
RE: How to add vertex to a user-defined position
2005-09-01 09:47
thank you so much for your kind reply , but I still got some problems, here is my code

public class MyVertex extends SparseVertex{
private int X ;
private int Y ;

public int getX() {
return X;
}

public void setX(int x) {
X = x;
}

public int getY() {
return Y;
}

public void setY(int y) {
Y = y;
}
}

public class MyLayout extends AbstractLayout{

public MyLayout(Graph arg0) {
super(arg0);
}

protected void initializeLocations() {

super.initializeLocations();
Vertex[] vertices = (Vertex[]) getVisibleVertices().toArray(new Vertex[0]);

for (int i = 0; i <vertices.length; i++) {
coord.setX( ((MyVertex) vertices[i]).getX() );
coord.setY( ((MyVertex) vertices[i]).getY() );
}
}
}

And when I run codes below , I got error at the last line ( graph.addVertex(mv); )

graph = new DirectedSparseGraph();
gd = new GraphDraw(graph);
MyVertex mv = new MyVertex() ;
mv.setX(100);
mv.setY(100);
gd.getVisualizationViewer().setGraphLayout(new MyLayout(graph));
vv = gd.getVisualizationViewer();
graph.addVertex(mv);

the error message is
java.lang.NullPointerException
at edu.uci.ics.jung.visualization.AbstractLayout.getX(AbstractLayout.java:248)
at edu.uci.ics.jung.visualization.VisualizationViewer.renderGraph(VisualizationViewer.java:696)
at edu.uci.ics.jung.visualization.VisualizationViewer.paintComponent(VisualizationViewer.java:636)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:557)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4794)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent.paint(JComponent.java:798)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1312)
at sun.awt.RepaintArea.paint(RepaintArea.java:177)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)
at java.awt.Component.dispatchEventImpl(Component.java:3678)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
java.lang.NullPointerException
at edu.uci.ics.jung.visualization.AbstractLayout.getX(AbstractLayout.java:248)
at edu.uci.ics.jung.visualization.VisualizationViewer.renderGraph(VisualizationViewer.java:696)
at edu.uci.ics.jung.visualization.VisualizationViewer.paintComponent(VisualizationViewer.java:636)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent._paintImmediately(JComponent.java:4685)
at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
java.lang.NullPointerException

thanks again for all your help.





 

By: Dhaval - dhaval04
RE: How to add vertex to a user-defined posit
2005-09-01 14:36
Gotcha.

You were not adding vertex to graph before applying MyLayout to it and that's why it created problem.

Following is your code:

graph = new DirectedSparseGraph();
gd = new GraphDraw(graph);
MyVertex mv = new MyVertex() ;
mv.setX(100);
mv.setY(100);
gd.getVisualizationViewer().setGraphLayout(new MyLayout(graph));
vv = gd.getVisualizationViewer();
graph.addVertex(mv);

Here you are adding vertex after you declare your layout. Below is the solution:

graph = new DirectedSparseGraph();
gd = new GraphDraw(graph);
MyVertex mv = new MyVertex() ;
mv.setX(100);
mv.setY(100);
graph.addVertex(mv);
gd.getVisualizationViewer().setGraphLayout(new MyLayout(graph));
vv = gd.getVisualizationViewer();

Changes: I put addVertex(...) after mv.setY(...). Now in MyLayout it can find vertex in that for loop of initializeLocations() and it can set X and Y co-ordinates of it. It should work for you as it worked for me.

Let me know how it goes.

Regards,
Dhaval



 

By: Nobody/Anonymous - nobody
RE: How to add vertex to a user-defined position
2005-09-01 19:07
hi , Dhaval
Thank you so much !! It worked for me !! Thank you for your great help!!

設定上の注意:

2005-09-19 00:01:59 | Weblog

localhost:8080と192.168.1.1(適当なローカルIPアドレス)を書き換えた場所:

  1. test.html ----HTMLファイル
  2. file_properties設定ファイル ←ここ localhostに設定するのは間違い!!
  3. WordNeterの URL field