Gaurav tyagigaurav

Greenhorn
+ Follow
since Jul 30, 2008
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 Gaurav tyagigaurav

I am getting the following error while creating a JSONObject:

Caused by: java.lang.IllegalAccessException: Class org.json.JSONObject can not access a member of class java.util.HashMap with modifiers "private"

The DTO has 3 properties:

The error is thrown while creating a JSON object at:

where object is the DTO object.
Not sure what am I doing wrong here or missing something. If i just have the list as the property then it works fine.
I would really appreciate any pointers to the soln.
Hi

I have a requirement where I need to redirect to Page2 instead of landing on the default Page1. I was planning to use the backing file handlePostbackData() method but the problem i am facing is that the control of the program does not go into this method of the desktop backing file. the URL i call from the login JSP is something like: "/../../myDesktop.portal" where myDesktop.portal is the desktop portal file having books and pages. I wanted to give the redirect logic in the handlePostbackData() method but the control does not go into the method. I also tried giving sth like : "/../../myDesktop.portal?_nfpb=true&_pageLabel=Page2" but it still renders the (default) Page1.
Do you have an idea what would I be possible missing out on or doing wrong here. Thanks.

I am using struts portals.

Thanks
GT
6 years ago
Hi Ilja

I am not sure how to pass the mock to the class under test. I think thats the issue here then.
Can you please let me know how can i pass the mock in the code?

Thanks
GT
9 years ago
Thanks for the reply Ilja.

Apologies for the typo. Please see corrections:

EasyMock.replay(feedStatusBean); => EasyMock.replay(statusBean);

Actually this is an existing controller for which i need to write UTs for. There is no default constructor in the StatusBean class. I am not sure if we can inject it anyhow.

Thanks again
GT

9 years ago
Environment:

SPRING
JUNIT 4.4
EasyMock 2.2
EasyMockClassExtension 2.2

Setup:
Controller to be tested:

The junit I have tried for testing the above controller:

Issue :
The "statusBean.getGroupsAsMap().values()" gives error while trying to fetch the real values, i.e. EasyMock is not mocking this. The class StatusBean does not have any corresponding Interface.

Any pointers would be highly appreciated.

Thanks
GT
9 years ago
Hi

I am trying to:
1. Create panel A containing Images/Icons.
2. Create Accordion B having some Image/Icon contents.
3. Icons of A should be dropable over Icons of accordion B.
3. On dropping Icon from A over Icons of accordion B a new window should open having grid data based on the properties from Icon that was dropped over.

I am new to smartGWT. The things i have tried already are:
1. Created a tile grid and accordion. Wasn't able to drag drop tile grid Icons on the accordion Icon as wasnt sure how to configure each tile. When i try to drag drop a tile on an icon of accordion it drag/drops the whole tile grid. I used XML datasource for getting the data. I used the sample Drag/Drop tile showcase example for a starter:
https://www.smartclient.com/smartgwt/showcase/#effects_dd_select_list

I retried using the original Tile Grid Drag/Drop example from showcase and just added another widget to it (an accordion). I tried drag/dropping the data first from the list grid to the tile grid (as given in the example) and then from tile grid to the accordion but i see the same result. The whole tile grid was dragged/dropped in the accordion stack section. Is this an expected behavior?

2. Created a tile layout and added individual tiles to it. Configured each tile to be dragable/dropable. I created the Icons similar to draggable pieces in the showcase examples. Defined the ondropover function for the Icons of the accordion. For the tile layout used Drag/Drop create as a starter:
https://www.smartclient.com/smartgwt/showcase/#effects_dd_create


I wanted to know if I am taking the right approach for the requirement? If No, then what widgets should i use? If Yes, then what could i be missing here.
Any pointers would be appreciated.

Thanks
GT
9 years ago
Hi

I have a DAO implementation as:

Now I need to fetch some data using SPRING JDBC template in the same DAO implementation. I am working on a running application and it uses both SPRING hibernate and JDBC template for DAO implementations but never in the same DAO implementor. The usage i have seen for JDBC template in my app is sth. like:

As we cannot extend 2 classes in JAVA so i tried instantiating SimpleJdbcDaoSupport and using it as:

This gives me a null pointer exception at queryForObject line.
Any pointers as to what i might e doing wrong here would be greatly appreciated.

Thanks
Tyagi
9 years ago
Hi

I am investigating probable memory leaks in my application. I was planning to use Netbeans profiler for it. But when i run the profiler on my app i get the following error:

Profiler Agent: Waiting for connection on port 5140, timeout 10 seconds (Protocol version: 8)
Profiler Agent Error: Timed out trying to establish connection with client
Profiler Agent: Initializing...
Profiler Agent: Options: >C:\Program Files\NetBeans 6.5.1\profiler3\lib,5140,10<
Profiler Agent: Initialized succesfully
Java Result: -1
BUILD SUCCESSFUL (total time: 10 seconds)

Assuming its taking longer to connect to the server, I tried increasing the timeout value but i could not find a way to do so. Any pointers as to what could be the possible issue here would be appreciated.

Thanks
Tyagi

p.s.: Tried googling the issue but with little luck.
Hi

Thanks for the reply. On your suggestion i mailed the Stinger author about this issues and this is the reply i got:

The filters apply to every http request, whether they are fielded by an included jsp or a main jsp. It doesn’t look to me like you have defined a rule for your parameter named “tNumber” – you need to tell Stinger what the format of that variable should be. If it’s just a single digit number then the regex would be something like \d or [0-9]. Good luck.

I tried doing this but still getting same errors. This is what i did:

1. Web.xml:

<filter-mapping>
<url-pattern>/ABC.jsp</url-pattern>
<url-pattern>/XYZ.jsp</url-pattern>
.....

stinger.xml:
<ruleset>
<name>ABC</name>
<path>/ABC.jsp</path>

<rule>
<name>load</name>
<regex>safetext</regex>
<missing>
<severity>continue</severity>
</missing>
<malformed>
<severity>continue</severity>
<action class="org.owasp.stinger.actions.Encode" />
</malformed>
</rule>

</ruleset>

<ruleset>
<name>XYZ</name>
<path>/XYZ.jsp</path>
<rule>
<name>tNumber</name>
<regex>safetext1</regex>
<missing>
<severity>continue</severity>
</missing>
<malformed>
<severity>continue</severity>
<action class="org.owasp.stinger.actions.Encode" />
</malformed>
</rule>
</ruleset>

where:

<regex>
<name>safetext</name>
<pattern>^[a-zA-Z0-9.\-_\/ ]+$</pattern>
<description>
Lower and upper case letters and all digits
</description>
</regex>
<regex>
<name>safetext1</name>
<pattern>^\d{1}$</pattern>
<description>
Single digit
</description>
</regex>

And to reiterate I'm passing the param as:

<jsp:include page="XYZ.jsp">
<jsp:param name="tNumber" value="1" />
</jsp:include>

in the ABC.jsp page.

2. I also tried including only the main (ABC.jsp) page in the filter and ignoring the included page.

In both cases I get an error:

java.lang.NumberFormatException: null
at java.lang.Integer.parseInt

When I try to do a
int tNumber = Integer.parseInt(request.getParameter("tNumber"));
In the page XYZ.jsp

Thanks for looking into this.
9 years ago
JSP
Hi

Thanks for the reply I am using OWASP Stinger filter for input validation. Excerpt from my web.xml and stinger.xml:
web.xml:
<filter>
<filter-name>StingerFilter</filter-name>
<filter-class>org.owasp.stinger.StingerFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>stinger.xml</param-value>
</init-param>
<init-param>
<param-name>error-page</param-name>
<param-value>/Error.html</param-value>
</init-param>
<init-param>
<param-name>reload</param-name>
<param-value>true</param-value>
</init-param>
</filter>

and

<filter-mapping>
<filter-name>StingerFilter</filter-name>
<url-pattern>/ABC.jsp</url-pattern>
</filter-mapping>

Ruleset from stinger.xml:

<ruleset>
<name>ABC</name>
<path>/ABC.jsp</path>

<rule>
<name>load</name>
<regex>safetext</regex>

<missing>
<severity>continue</severity>
</missing>
<malformed>
<severity>continue</severity>
<action class="org.owasp.stinger.actions.Encode" />
</malformed>
</rule>
</ruleset>

Hope this helps. Please let me know if you need any other info.

Cheers
Tyagi
9 years ago
JSP
Hi

I have a JSP (ABC.jsp) and a filter that is setup to include this jsp. I have another jsp that is included in ABC.jsp (XYZ.jsp) as:

<jsp:include page="XYZ.jsp">
<jsp:param name="tNumber" value="1" />
</jsp:include>

But in ABC.jsp the value of the param(tNumber) is coming as NULL. If i remove the filter on ABC.jsp then everything works fine. My understanding was, correct me if i am wrong, that the filters do not apply to the included pages anyways.

Any help would be really appreciated.

Cheers
Tyagi
9 years ago
JSP
Hi

Has anyone used the OWASP stinger framework before? I am trying to configure it on my local setup. But i am running into error:

java.lang.NoSuchMethodError: org.owasp.stinger.http.MutableHttpRequest.getRemotePort()I
at org.owasp.stinger.actions.Log.doAction(Unknown Source)
at org.owasp.stinger.Stinger.handleViolationActions(Unknown Source)
at org.owasp.stinger.Stinger.checkMissingParameters(Unknown Source)
at org.owasp.stinger.Stinger.doValidate(Unknown Source)
at org.owasp.stinger.Stinger.validate(Unknown Source)
at org.owasp.stinger.StingerFilter.doStinger(Unknown Source)
at org.owasp.stinger.StingerFilter.doFilter(Unknown Source)

I have placed the jar file (downloaded from the OWASP website) in the web-inf/lib folder and configured the filters in the web.xml.

Any pointers would be appreciated.

Cheers
Tyagi
9 years ago
Hi Guys!!!
I had exactly the same doubt that is stated in the original Q. Didnt know where to look for. Thanks to Java Ranch found the soln. here. Java ranch rocks [ ]. I however in the mean time was wondering how could i write/test the code to find out how many objects get created. Any idea how can we modify the above code to find out the number of objects created?

Cheers
Gaurav
Hellooooooooo !!!
Is this the right place/forum for requesting this? No one seems to be responding ....

Cheers
Gaurav
Hi

Even i am looking for SCJP 1.5 voucher in the US. If anyone is willing to sell it.Please mail me at gtyagi.123@gmail.com

Cheers
Gaurav