Hugh O'Donnell

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

Recent posts by Hugh O'Donnell

Man, that's pretty sweet. I wouldn't have thought of that. But it's no biggie for me to do it that way I am. Can I ask how does your converter class access the AccountService? The converter class is mentioned in the @TypeConversion annotation, but I thought a new converter would be instantiated every time? How does it handle the injection of beans from the Spring application context?

Regards,
Hugh
16 years ago
Hi Eric,

I dont' see why they couldn't have done it in two passes, one to validate the fields, and another pass when all validation passes to apply the updated values. Hopefully they can sort it in the near future. As for me, I think I'll abandon ModelDriven for now, add the extra setters in the Action, and when validation passes, I'll update the Hibernate entity manually in the execute() method. I'm going to have to do this anyway to resolve dependencies from form dropdowns with other Hibernate tables.

E.g. updating an Account model object but the AccountType is determined by a dropdown.

public String execute() {
// Resolve AccounType from the selected dropdown
AccountType accountType = accountService.findAccountTypeById(accountTypeId);
account.setAccountType(accountType);

// set account fields from form..
account.setName(name);
account.setSurname(surname);
accountService.saveOrUpdate(account);
}

Thanks again,

Hugh
16 years ago
Hi Eric,

Thanks for the reply, much appreciated. Yes, I'm sure it must have been your thread I came across :-) I do agree about the domain validation and the package naming. I was aiming to use the extra setters on the action as a kind of firewall between the form data and the hibernate object. Am I right in thinking that when using ModelDriven, the model is updated with every successful field validation? This seems wrong, as if the first field passes, the Hibernate entity is updated (marked as dirty), then the rest of the fields fail, but leaving you with an altered Hibernate entity which may cause database activity. I'd rather make sure all validation passes, before the Hibernate entity is even touched.

Regards,

Hugh
16 years ago
Hi all,

I want to use annotation validations and ModelDriven for an action working with a Hibernate entity for the model. But I'd prefer not to put Struts 2 annotations in the entity class, but in the action instead and keep them in the web tier. Does this mean I just add the appropriate setters in the action (which update the model), then annotate these setters? Anybody got an example of this?

I know adding extra setters in the action goes against the DRY principle, since these setters already exist in the Hibernante entity, but there seems to be well known problems with ModelDriven where, when validation fails for a setter, previous setters may have passed and update the Hibernate entity, thus causing it to be persisted when the session is flushed. Also the fact that adding Struts 2 annotations (web tier) to Hibernate entities (business tier) just sounds nasty.

Any advice would be much appreciated.

Cheers
16 years ago
Hi all,

I'm a software developer with 9 years experience. I quit my job 16 months ago to study and get qualified in Java and now have enough to take some contracts. Does anyone know how much I can expect to earn per hour in the UK, and also any good job sites out there you would recommend?

Any help would be much appreciated.
19 years ago
Hi all,

Just passed this morning. Exam wasn't too bad, a lot more EL than I was expecting, but I must say those Head First books are magnificent and really came through for me.
19 years ago
That did the trick exactly, thanks a million Sonny. I didn't realise I had to specify jsp-file instead of servlet-class.
20 years ago
JSP
Hi all,

I've just started using Resin and it's fantastic, but I'm having a bit of trouble with something that should be very simple. I have the following in a file in resin-3.0.9\webapps\jsptest\hello.jsp :

Hello World!

In resin-3.0.9\webapps\jsptest\WEB-INF\web.xml I have the following :

<web-app>
<servlet servlet-name="jsppage"
servlet-class="hello">
</servlet>

<servlet-mapping url-pattern="/hello"
servlet-name="jsppage"/>
</web-app>

However, the problem is, when I type the URL http://localhost:8080/jsptest/hello I get the following

error from Resin :

500 Servlet Exception
WEB-INF/web.xml:4: `hello' is not a known servlet. Servlets belong
in the classpath, often in WEB-INF/classes.

--------------------------------------------------------------------
Resin-3.0.s041002 (built Sat, 02 Oct 2004 04:47:31 PDT)

I just don't get it. When I delete my web.xml file and try the URL http://localhost:8080/jsptest/hello.jsp it works fine. I have tried to manually compile the .jsp file but to no avail. I just want to be able to have a mapping between a URL and a .jsp file. Can anyone see what I'm doing wrong? When hello.jsp is compiled by Resin, I am assuming it is compiled to hello.class, as specified in my servlet-class="hello". I think this might be the problem.

Any help would be greatly appreciated.
[ October 11, 2004: Message edited by: Bear Bibeault ]
20 years ago
JSP
Hi all,

I've just started using Resin and it's fantastic, but I'm having a bit of trouble with something that should be very simple. I have the following in a file in resin-3.0.9\webapps\jsptest\hello.jsp :

Hello World!

In resin-3.0.9\webapps\jsptest\WEB-INF\web.xml I have the following :

<web-app>
<servlet servlet-name="jsppage"
servlet-class="hello">
</servlet>

<servlet-mapping url-pattern="/hello"
servlet-name="jsppage"/>
</web-app>

However, the problem is, when I type the URL http://localhost:8080/jsptest/hello I get the following

error from Resin :

500 Servlet Exception
WEB-INF/web.xml:4: `hello' is not a known servlet. Servlets belong
in the classpath, often in WEB-INF/classes.

----------------------------------------------------------------------
Resin-3.0.s041002 (built Sat, 02 Oct 2004 04:47:31 PDT)

I just don't get it. When I delete my web.xml file and try the URL http://localhost:8080/jsptest/hello.jsp it works fine. I have tried to manually compile the .jsp file but to no avail. I just want to be able to have a mapping between a URL and a .jsp file. Can anyone see what I'm doing wrong? When hello.jsp is compiled by Resin, I am assuming it is compiled to hello.class, as specified in my servlet-class="hello". I think this might be the problem.

Any help would be greatly appreciated.
20 years ago
Hi all,

Just passed SCBCD this morning, and got a much better score than I expected. Head First EJB came highly recommended by this site and certainly didn't disappoint, well worth it.
20 years ago
Hi all, just got my results after an agonising 32 day wait. The worst thing is that I struggled away on my own, and only discovered the Java Ranch forums when I had it nearly complete. It was great to see that everyone here is so supportive and helpful. I have the SCBCD to take next next week, so no doubt I'll have a few questions.

Comment: This report shows the total number of points awarded for each section. The maximum number of points is 400, to pass you need a score of 320. Section Summary: Section Max Actual Points Points General Con: 100 92 Documentation: 70 70 OOD: 30 15 GUI: 40 40 Locking: 80 80 Data Store: 40 40 Network Server: 40 40 Total: 400 377


Hugh O'Donnell

SCJP SCJD
20 years ago
Thanks for the help guys, but unfortunately still no luck.
I did try as you suggested Stefan, using the following manifest in mainapp.jar :

Main-Class: com.efinery.RunTest
Class-Path: test.jar .
<a blank line here>

Marilyn, as you asked, you I am running from the directory that contains the jar. Also in the same directory is the original test.jar that is also inside mainapp.jar. I should say that mainapp.jar contains no java code, only some documentation and source code. I simply want the mainfest in mainapp.jar to run the manifest in the nested test.jar.
20 years ago
Is it possible to run a jar file that is contained within another jar file? I have tried and can't seem to get it to work.
I have the following manifest in test.jar :

Manifest-Version: 1.0
Main-Class: com.efinery.RunTest

This runs fine using "java -jar test.jar" from the command line. However, when I place it inside a jar called mainapp.jar and have it's manifest reference test.jar in the Classpath as follows :

Manifest-Version: 1.0
Main-Class: com.efinery.RunTest
Classpath: test.jar

When I try to run "java -jar mainapp.jar" I get a java.lang.NoClassDefFoundError. Can anybody tell me what I am doing wrong? Any help would be much appreciated.
20 years ago