sony vijay

Ranch Hand
+ Follow
since Jun 27, 2010
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
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sony vijay

I really want to break the first group before _feed starts. So, the following works



12 years ago
Hi,

Say, I have a String like so: ts_20120413_dot_175531_dot_463_feed_user_at_gmail_dot_com_filename

This is a file name in the database which is prefixed with a timestamp, all dots and @ are replaced with _dot_ and _at_. I need to create a Pattern that matches Strings of the above type which can be split into three groups like so:

group1: ts_20120413_dot_175531_dot_463
group 2: user_at_gmail_dot_com
group 3: filename

I tried:



The above code snippet throws the error: Invalid file name.
The expected output is:
Group 1 is: ts_20120413_dot_175531_dot_463
Group 2 is: user_at_gmail_dot_com
Group 3 is: filename

I can't figure out how to fix the error

- Sony
12 years ago
Hi,

I am trying to convert a Java String into a JavaScript object and pass it to a JavaScript function in a .js file. Please note that the "fields" String in my code below is not of JSON format but is in the format of a JavaScript Object literal. That is the keys are not Strings, not enclosed in double quotes. So, I need to convert it into a JavaScript Object and not a JSON Object. Please see my simplified code below:




test.js


When I run the Java Code, the following error is thrown when the transform function is invoked:
sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot read property "length"

Thanks,
Sony

Okay thanks. I just wanted to double check if my coding practice was fine
12 years ago
Hi,

I create two objects of Test Class and call initialize method of Test Class in InitializeTest.java. However, I am passing the same textbox component to the initialize method through both the objects.

Passing same textbox twice looks redundant to me. What is a better way to send the textbox component to Test Class such that it can be used commonly by both objects test1 and test2 ?

I simplified the code for better readability but the task I am trying to achieve is that I need to pass textbox from IntializeTest to Test only once and use it commonly by both the objects test1 and test2. In other words, I do not want to create textbox in Test Class.





12 years ago
Hi,

Answer: I guess using StringUtils.subStringAfter() function should do this. I am not sure how to delete the post so am posting the answer myself

Question: Say I have a String like so: "prefix_somestring"

Is there a way to find substring after the separator "prefix_" i.e. the output should be "somestring"

12 years ago
Hi,

My code actually works. I ran into a small syntax error. I resolved it. I can't figure out how to delete the post so I guess I will let my question stay on this forum.

I am trying to understand how to use Pattern Matcher in Java. Please see my code below:



I expect the following outputs when I call getOutput function like so:
-- For Input: "abc_userid_name", expected output: "abc@userid@name"
-- For Input: "def_userid_name", expected output: "def@userid@name"

But, when I pass abc_userid_name, the above code throws an error i.e. Invalid doc name: abc_userid_name
Please help me fix this.

Thanks,
Sony
12 years ago
@Matthew Brown: Please see my edited question. Although, I am using ZK Ajax Framework, I think the issue is still with my java logic and not really ZK specific. I hope my code makes sense to non zk users.
12 years ago
Hi,

Is there a way to refer to a non-static field of an outer class from a static nested class?

Please see my code below:



This code throws an error at testLabel.setValue(value) as I am trying to make a static reference to a non-static field. But, I need the value to be non-static and yet reference it in the static nested class's method. How do I do it?

You may notice how I instantiate TestComponent.java here: http://top.cs.vt.edu/~vsony7/patches/gfc.patch

The idea is to create two labels dynamically with two different values "Label 1" and "Label 2" and append them to two different Components i.e. vlayout1 and vlayout2. But, when I run this code, a label gets attached to each of the layouts but the value of both the labels is "Label 2". You can test this at:

The problem is that the two windows from testlabel.zul created by two calls to IncludeBuilder share the static class TestLabel. After the super.doAfterCompoe() the value of test label is set to "Label 2" in both the calls.

I am using Zk framework and ZK does not have an enclosing instance so the inner nested class TestLabel must be static.

Thanks,
Sony

12 years ago
Hi,

I am using ZK Ajax Framework and am using Java code to control the components. The idea is to create two labels dynamically with two different values "Label 1" and "Label 2" and append them to two different components i.e. vlayout1 and vlayout2. But, when I try this code, a label is attached to each of the vlayout but the value of both the labels is "Label 2". I am not sure what's wrong, how do I fix this such that the values of labels are created dynamically?

I am not sure if the question is appropriate in this forum but I think the issue is with my Java code (perhaps the way I am using the static class) and not something very specific to ZK. It would be great if someone helps me figure this out. Please see the simplified version of my code below:


TestComposer.java


TestComponent.java


IncludeBuilder.java


testlabel.zul


testcomposer.zul


Thank You,
Sony

12 years ago
Hi,

Say, I have a file like so:

3
4
1,2,3,4
5,6,7,8
9,10,11,12

The first line represents the number of rows and the second line represents the number of columns. Thereafter, each line represents the data of a 2D array. I am using the following code to create a 2D array from the input file in Java.



The above code works. But, my task is to modify the code in order to create a 2D array from the array data directly without having to specify the rows/columns in the input file. The input file would now look like so:
1,2,3,4
5,6,7,8
9,10,11,12

My code should be able to read this file and dynamically create a 3*4 array. I am not sure how to do that. Thank You!

12 years ago
Thanks! That was a useful link. But, I am trying to just check the syntax errors for now. Any idea if there are any differences between Java and Javascript regular expressions?
12 years ago
@Campbell Ritchie: I would use the the java regex Patterns to check whether a string is a regular expression:

import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

I would do a Patter.compile(input) within a try-catch block. The catch block would throw a PatternSyntaxException. I hope you get the general idea. Please let me know if you need more explanation. But, I am not sure whether the the java Pattern of regular expressions matches the javascript regular expression patterns. I am yet to check on that.
12 years ago
Hi,

I am trying to perform some rule checking in my application. I am using an inner interface(Check) within a class and am creating anonymous classes of the type interface(Check). Using this approach, the idea is to create an anonymous class for each rule. Please see code below:



But, I am not sure how to call the methods of anonymous classes from another class? Say, there's another class called TypeCheck. How do I call the IS_NUMBER.check method?


I have never used interfaces with anonymous classes before and I am trying this out. Thank YOU!
12 years ago