chandru ram

Greenhorn
+ Follow
since Jul 03, 2002
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 chandru ram

Hi all,

I want to add struts-validator to the user registration form.

I have a ActionForm UserRegistrationForm, which is used in two different flows, add new user flow and modify user profile flow. Also the same jsp page is re-used across these two flows. In the modify profile flow the password field will not be displayed in the page. There will be a property in the UserRegistrationForm "actionType" the value of which will be "Create" or "Modify" based on the flow.

The password field has validations like require,minlength,maxlength etc. But i have to validate the password field only when the property "actionType" has a value "Create". Can this be done using validWhen validators. I have to do only server side validation.

It would be helpful if there are some sample on how to configure validWhen in the validation-rules.xml

Thanks in advance
Regards,
chandru ram
19 years ago
Hi,
Im trying to call a method on the swing component from javascript. but the browser gives an javascript error dialog box as "Object doesn't support this method or property". pls help. iam attaching the code of both html and the applet.

applet
------

import javax.swing.JLabel;

public class TestApplet
extends javax.swing.JApplet
{

public void init()
{
this.getContentPane().add(new JLabel("Harsh"));
}

public void callMe()
{
java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
public Object run() {
// do priv stuff here.
System.out.println("Applet Method called");
return null; // return whatever you want.
}
});
}
}



HTML
-----

<html>
<body onnload="callAppletMethod();">
<script>

function callAppletMethod()
{
alert("Inside function");
alert("document is"+document);
alert("document all is"+document.all);
alert("testApplet is"+document.TestApplet);
alert("testApplet callMe is"+document.TestApplet.callMe());
document.TestApplet.callMe();

}

</script>



<OBJECT

classid= "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"

codebase= "http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0"
WIDTH="775" HEIGHT="400" NAME="TestApplet">

<PARAM NAME = CODE VALUE = "TestApplet.class" >
<PARAM NAME = "type" VALUE = "application/x-java-applet;jpi-version=1.4.1">
<PARAM NAME = "scriptable" VALUE = "true">
<PARAM NAME = "mayscript" VALUE="true">

<COMMENT>
<EMBED
type = "application/x-java-applet;jpi-version=1.4.1"
CODE = TestApplet
scriptable = false
pluginspage = "http://java.sun.com/products/plugin/index.html#download">
<NOEMBED>
</TaskModel>'>
</NOEMBED>
</EMBED>
</COMMENT>
</OBJECT>

</body>
</html>

Im using IE 6.0. the jdk version im using is 1.4.0
The strange thing is the same code works on some different machines. but im not able to trace what is the difference.

pls help

thanks in advance
chandru ram
Im using IE 6.0. the jdk version im using is 1.4.0
The strange thing is the same code works on some different machines. but im not able to trace what is the difference.

pls help

thanks in advance
chandru ram
Im using IE 6.0. the jdk version im using is 1.4.0
The strange thing is the same code works on some different machines. but im not able to trace what is the difference.

pls help

thanks in advance
chandru ram
19 years ago
Hi All,
Are the Session listener events synchronous or asynchronous??.

Can the Listener event class be used to interact with the database.

For example, when i set an attribute to a session, the container will invoke the attributeAdded method of the listener class. Now i want to store the session data in a database.
can this process of saving to the DB be done inside the attributeAdded method of the listener. is this a proper design.
Also do the container call the listener's method from the same thread of execution of the client. (i.e) a request will have a thread to access the servlet. If we set a value in session, the container has to invoke the listener. So does the container do this within the same thread or it uses different threads to invoke the listeners asynchronously??
Thanks in advance,
Chandru ram
20 years ago
yes this is a bug with previous releases. please see this link for more details:
http://www.sys-con.com/story/?storyid=34292

Regards,
Chandru ram
20 years ago
Hi All,
I tried the following example
class A {
public void print(int a) {
System.out.println("method from class A accepting int: "+a);
}
public void print(long a) {
System.out.println("method from class A accepting long: "+a);
}
}
class B extends A {
public void print(long a) {
System.out.println("method from class B accepting long: "+a);
}

}
public class Test {
public static void main(String args[]) {
B b = new B();
b.print(5);
}
}
When this program is compiled, there is a compilation error like :
Test.java:23: reference to print is ambiguous, both method print(int) in A and method print(long) in B match
b.print(5);
^
1 error

When we try to do this operation base class alone like A a = new A(); and then a.print(5).it works correctly. the compiler associates the call to the method accepting int as parameter.
but why this doesn't happen when the method is over-ridden?
pls explain.
Thanks in advance,
chandru
20 years ago
it will be helpful if someone has some piece of code. bcoz i tried a lot of samples with the Number and decimal format classes.

Thanks & Regards,
Chandru
20 years ago
I want to validate the value that a user enters.
for ex:
if the user enters a value (in String) like 1,000 or 1000 it is a valid one. But if the user enters a value like 1,00 it is invalid and an exception should be thrown. (i.e) i want the numbers to be having "," as the group separator and the separator should only appear for the thousands.


I tried some samples with DecimalFormat but not able to achieve this result.Can any classes from java.text package can be used or we have to write our own logic to perform this test.

Thanks in advance,
Chandru Ram.
20 years ago
Hi All,
Consider an application that has many different flows like addition,modification of a record etc.Each flow has to show a jsp page in different ways. for ex consider the following:

there is a page jsp1.jsp.If the flow is addition of a record, the jsp1 should show some values as text boxes and drop-downs.But if the flow is modification then the jsp1 should show the same fields as lables instead of textboxes.


If the number of such conditions are more then it results in lot of if-else conditions in the jsp page.If we write two separate jsp pages one for addition flow and one for modification flow (e.g jsp1_add.jsp and jsp1_mod.jsp) then if there is a change like adding a new field etc, then it has to be done at two places.

So what is the best solution for this.Does using Tiles solve this.

Thanks in advance,
Chandru ram
20 years ago
JSP
I saw an application that is using the following design for ValueObjects:
public class RequestVO {
public void setName() {}

...... similarly other methods.

}
public class ResponseVO extends RequestVO {
}

Like this the response extends the request VO. Is there any advantage of using such a design.I need some comments on this.
Thanks in advance,
chandru ram
Hi jason,
note that i have changed my name according to the rules.
consider the containers of the application servers.The values are serialized before passing to remote clients.in these cases does using null have a performance gain.

thanks
chandru ram


Howdy Chandru, we don't have many rules at the Ranch, but we do have some naming ones we like everyone to abide by. Click here, and then click on the My Profile link to change your name (you need a first and a last).
As far as your question, what type of stream are you talking about? For instance, if you are using an ObjectInput/OutputStream, then serializing null will cause null to come out on the other end.
As far as performance, I couldn't imagine there being much difference over using null versus an empty String. The empty String still creates an object, so you're actually serializing/deserializing something, but it's a really negligible something.
20 years ago
Hi,
I have a question on serialization:
If an object say a String Object whose value is null is serialized.
how will it be represented in the stream.

If there are 2 Strings whose values are null and empty string.which one will give a better performance when serialized. {i.e.) does having a value as null gives good performance while serializing.
Thanks in advance,
Chandru
20 years ago
Hi all,
can a jsp file which is in a different application(project) can be included in a jsp file in another application using <jsp:include>.
for ex : if jsp2 of application2 is included in jsp1 of application 1, then it means that any submission from jsp2 has to go thru jsp1.
is using frames a good solution for this.
thanks
chandru
20 years ago
JSP
Hi,
Thanks all for the reply.
Iam trying out a solution based on the one posted by Naren.

Chandru
The value of zero for the attribute is the required condition in my application. so IllegalArgumentException would be misleading.
Thanks
Chandru
I have an XML document in the following format :
<Response>
<Return code="0" />
....
.....
Now in the SAX parser i want to check the value of the attribute code.If the value is not zero an exception should be thrown.
In the startElement method we can check for this condition.But if the value of code attribute is zero, i have to stop the parsing. how can it be done.