Rory Evans

Greenhorn
+ Follow
since Feb 19, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Rory Evans

Thanks for the links Amit.

I think I'll give the example in your second post a go. Although I'm planning on using the @Autowired annotation to wire in my UserDAO - this should save me having to manually get the Spring Context.

Apologies for marking this as a Hibernate question - upon further inspection it's more to do with injecting Spring managed beans into a servlet.

Thanks
Hi,

I currently have a project that is configured to use Spring and Hibernate (I let Spring take care of setting up Hibernate). I am successfully using Spring injected beans throughout my application and have also tested to make sure Hibernate is set up correctly.

I have created a servlet that checks incoming requests for request parameters and does a database search based on them. I would like to use Hibernate to do this but am not sure how to use it from my servlet. Can anyone provide an example/suggestions?

I also have a Spring managed DAO which I'm using for all my persistence handling. Preferrably, from my servlet I'd call find() on my DAO. So I guess my question is more 'how do I Spring inject Spring managed beans onto my servlet'?

My servlet currently looks like this:



Thanks
A name? Or map it first? Sorry to be dumb, but do you have a snippet of an example web.xml which shows these options in practice?

Thanks
14 years ago
Thanks for your comments David. If I don't add some kind of extension to the link, how can I specify in my web.xml which requests the Activation Servlet should deal with?
14 years ago
I am planning on creating an Activation Servlet that handles the user clicking on the activation link in their email. So, I could create each activation link with a .act extension and then have the Activation Servlet kick in for all requests with the .act extension. I could then obtain the email address and token as request parameters from the activation link and search the database for matching credentials. If a matching user record is found in the database, change the status from PENDING to ACTIVE.

I have never implemented a system like this before and am just asking if this approach is sensible. Or have I over-engineered the solution???

Thanks
14 years ago
With regards to generating a token, is it a good idea to use Java's UUID.randomUUID() method or is there a better approach?
14 years ago
Hi,

I'm attempting to implement the following use case:

1. User goes to web page and enters email address and password

2. System assigns unique token to this user and sends an email to supplied address. This email contains an activation link that includes the unique token for this user

3. User clicks on link in email and their account is activated

I have seen this done using Spring Security, but would like to know if it is possible (and fairly straightforward) to achieve the same result using standard java libraries (in other words, i'd like to avoid using 3rd party libraries such as spring-security).

Thanks
14 years ago
Hi,

On my backing bean, I have a list of Player objects. Each Player object has a list of Card objects.

On my jsf page, I want to display a dataTable with one row per Player and one column per Card. Since each player may have a different number of cards, I need to have a way of determining how many columns to create.

My initial idea was to use something like:



but this renders no columns at all (after reading around the subject, I understand why this is the case). Can anyone suggest a suitable alternative or workaround for the problem described above?

Thanks
14 years ago
JSF
Hi everyone,

I have an application that compares sets of images and identifies if there are any duplicates. The user is then shown a list of thumbnails of the duplicates and has the option to delete them.

This all works great, but I'm concerned about the performance of the thumbnail generation. The quality of the thumbnail does not matter - the priority is to get the thumbnails generated as quickly as possible.

I can't seem to find anything through google that suggests a 'quick and dirty' thumbnail generation algorithm that has performance as its priority.

Any pointers or advice of how to achieve fast thumbnail generation (even if it means using a third-party library) would be much appreciated!

Thanks
14 years ago
*** DISCLAIMER ***
I have absolutely no experience of Java FX - but from your description (the file only plays once and then never again) I'd say that when a file has finished playing, its play position doesn't get set back to the beginning of the track.

This would mean that calling play() again would cause nothing to happen since the play position is already at the end of the track.

I had a quick look at the API and noticed that under the stop() function it says 'Stops playing, resets to beginning of media, and resets the play count'.

The play() function says 'Starts or resumes playing'.

I would say that you need to call stop() before calling play() so you can ensure the track will always play from the beginning.
14 years ago
Try renaming the truncateBeansString() method to getTruncateBeanString()
14 years ago
JSF
The API for outputtext makes no mention of a parameter such as 'maxLength'.

I would have a method on a backing bean which in turn gets the string you want displayed and truncates it.

Maybe something like:



With a method on your backing bean like:



Where 10 is your desired number of characters to display in the outputtext
14 years ago
JSF
I would be slightly cautious of using css to convert text to uppercase. This is because it only APPEARS as uppercase - the raw data is still in the exact case that you entered it.

This has caused problems for me on search screens where I am trying to match a search string with a record in the database. For example: the string 'USER1' is stored in the database. You type 'user1' into the search field on your jsf page (although, due to the css style, what you'll actually see is 'USER1'). You hit go and the application tries to match your search string with any records in the database. Of course, 'user1' is not the same as 'USER1' and so no matches are found. To the user, this appears very wrong since they are under the illusion that their text was converted to uppercase and the search should have therefore returned the record 'USER1'.

Hope this helps
14 years ago
JSF
When I need to unit test code that relies on web service calls, faces context objects etc, I tend to use JMock. JMock can be used to mock interfaces (although you can also mock concrete classes - search for ClassImposteriser).

This way you don't have to worry about setting up objects that you're not interested in testing - you simply mock them and tell JMock that a certain method on an object will return a certain result. This gives you the ability to truely 'unit' test the code you're interested in without having to rely on other classes.

This approach is very handy when your code relies on classes that other people are developing. All they need to provide in order for you to unit test your code, are the interfaces. You can then tell JMock how the methods defined on the interface should behave.
14 years ago
JSF

Ernest Friedman-Hill wrote:Just with a loop:

>



In the above code, shouldn't it read

Otherwise, the loop will start with element 1 of the array rather than element 0.
14 years ago