Praveen Kumar Singh

Ranch Hand
+ Follow
since Mar 04, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Praveen Kumar Singh

Hi All,
I need to develop a AJAX application as part of my new project.
Requirement is simple, keep client and server separate!!
Idea is, if tomorrow we remove HTML by android or IOS thing should work.

so as my previous project, i started with JSON object for communication, however a bug i left in my previous project now grown enough to bite me!
BUG is FORM!

how to generate form using json or keeping client and sever separate!
My solution of previous project, create HTML on server, get it on client and replace div by that is no longer a feasible solution as we are developing this application for web, ios and android.
So guys, please help me here.

WORK SO FAR
1. jQuery.dForm plugin --- ahh good, but bit cumbersome to work with, getting div, validation message in between is difficult to put

Thanks Steve and Anayonkar
But, i am still not convince, it has to be some better, simple and straight forward solution.
Lets understand the situation one more time.
The chances that i will flush is very rare, may be once or twice in a month.
But, thread which will access the will be more than 1000 in a minute.
Having synchronization, still seems a costly deal!
Hi, i have a situation like below code.
what i am doing here is populating the products on start up and the getProduct method iterate over list and get the suitable product.
My doubt is, do i need to make this synchronized ?
classical problem is, lets say T1 is iterating over products and T2 enter in clearProduct->populateProducts and flush all the products while T1 is reading it.
if i have to, then won't system will very slow?
Does someone has better solution ?



Jeff Verdegan wrote:It is absolutely, 100% per HashMap or HashSet instance. There is no sharing across the JVM or OS.

AND
Iteration is O(N) for all collections,



Thanks Jeff, it was helpful.


Jeff Verdegan wrote:Eh? One doesn't typically iterate through a phone book.


Not convince jeff!!...you, specially in touchscreen phone, people iterate it on phonebook using right side scrollbar, also, i need to support the use case where user can enter in phonebook and press the down button one by one to SCROLL the contacts, try in your phone, it will work :-)



7 years ago
@Martin: Hi Martin, thanks for reply, i need to check the documentation to know properly is hash bucket Map's object wise or OS/JVM wise.

@ALL: It seems like everyone is convince that HasMap or Hashing mechanism give the faster result, but as part of my question another requirement was iteration too.
Do any one feel or Know that getting all elements from all buckets and making them a list i.e. entrySet, could be performance hit
In my application, no of time you do searching is almost equivalent to iteration (please check my phone book example)
7 years ago
Hi,
I have requirement to search a object from list 10-10000 objects, all will be unique and chances of just simple iteration is also almost similar (Consider a phone book case: chance of search ~ chance of iteration )
I am confuse here, which one is better way.

HashSet or Collections.binarySearch or TreeSet

After few hour of googling, i come to know that HashSet gives you O(1) search complexity whereas Collections.binarySearch O(log n).
First of all, i am not getting how O(1) is possible.
Fine, you will get the hashbucket with O(1) complexity, but what after that?
You have to do a liner search in the bucket, where not only your objects but rest of the application's and even your application's objects are present.
and definitely, we have three way to search in Java, so we must have some pros and cons!


7 years ago
Hi Miku,

BindingResult holds all errors detail
Flow is like, when you submit the form, you always connect it with a bean, now in sprng 3 we can actually put the annotation on beans for validation purpose
like, size of name, min and max value of int and so on
If validation failure happens, all failure information you can retrieve by BindingResult
7 years ago
I have a spring 3 Controller with signature


I need to write the jUnit test case for it, problem is i am struggling to get BindingResult result instance.
Is there any better way to do Spring MVC jUnit test, i was looking for mocking library, but yet not got any better answer.

Please help
7 years ago
GOF = Gang of four
7 years ago
Any update guys?
7 years ago
Hi,
I am trying to built an GOF type (not spring DI singleton) Singleton class in spring.



As, it is clear that to access the bean "userAuthenticationService", i need to fetch it from application context, hence i need to configure PrivilegesMgr in application context
After some R&D, i got the way




My problem is
Singleton class, traditionally called as PrivilegesMgr.getInstance() and not privilegesMgr.getInstance()

when, try to do PrivilegesMgr.getInstance(), i get null pointer, which is logical, as their is no bean available.
Any suggestion ?
7 years ago
Thanks Paul and Matthew
Its end up in wrong implementation only !
I almost presume that error is in 'generic' logic only
Final code



Thanks Wouter
Its works very well
I definitely need more study on Generics !

Thanks Rob
Look like you are an expert on generics

7 years ago
Hi
For Input: [abc, abb, aaa, bbc]

Collections.sort give: [aaa, abb, abc, bbc]

I tried to implement something similar to it like this



But what i get is: [abb, aaa, abc, bbc]


Why ?.....Any Help !!

7 years ago
Hi Joy,
Due to some reason i cant used spring in my application.
So i m trying to find the way, which similar to spring.
same time i also want to know, do this whole 'spring concept of DI' is worth of something.

Having said that, a protected constructor can provide the needs, what you are looking from spring in your example.
Idea is to know the best way, when we cant use spring.
7 years ago