Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Ken Rimple

author
+ Follow
since Jul 20, 2010
Ken likes ...
Mac OS X Spring Ubuntu
I'm a consultant and education specialist, having spent most of my career mentoring and educating others both internally and for my clients in a wide variety of technologies.

I currently work for Chariot Solutions, a consulting and training firm, located in Philadelphia, PA.  I teach SpringSource's Core Spring and a variety of other courses, direct the training team, and mentor others in Spring and maven.
Philadelphia, PA
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
3
Received in last 30 days
0
Total given
14
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ken Rimple

Rahul Dayal Sharma wrote:Thanks for the list of requirements sir,
I am making a project in Core java, where I have to make an attendance application residing on the main network ( or rather a server ) and whosoever has access to that network can access the application, open his account and enter his attendance date and time. I would like to know, if there is any way I can create something with the functions similar to the connection pool using the frameworks in order to enable multiple users to access that app and enter his attendance which would be stored in Microsoft Excel using JDBC.



I am a bit confused by your question.

Do you want to build a swing/java fx(Java graphical) application that would run on a client, or a server-side application with a web interface? Excel is not a safe destination for a multiple user database. You could give people download-only spreadsheets easily with Spring MVC using JExcel or Hssf from POI. But apI would use a real database, like postgres or mysql, or even derby/hsql, and use at least a c3p0 or Apache DBCP for the connection pool. Both of those can be mounted as datasources in Spring.
8 years ago
Yes, congratulations, all!

Ken
8 years ago
Also i had posted something a while back with the gist of what I was stating above.

Roo and Web Flow

Best,

Ken
8 years ago
Thank you to everyone who asked us questions this week. I had fun answering them and hopefully you found some of what I said interesting.

Resources:

rimple.com - my blog where I write about Roo, Spring and other topics
Roo in Action homepage - including free chapters and news, forum
Official Spring Roo forum (VMware/Springsource)
Twitter - @RooInAction
Twitter - me

Best,

Ken
8 years ago
Roo only creates Spring apps. So, you're giong to be working in Spring directly if you use Roo.
8 years ago

Rob Ivan wrote:Hi, Srini.

Thank you for responding. I was working on a web UI navigation based workflow like Spring WebFlow framework. I wanted to walk a UI user through a specific set of steps to build up an advertisement or flyer that they could then print out.



Yes, Roo does not quite deal with WebFlow completely out of the box - for example, the way webflow handles buttons and transitions is not matched by the current forms and buttons. The setup simply does the bare minimum to set up web flow, but doesn't integrate it into the whole ITD and scaffold world.

I had a draft chapter on this in roo in action, but it got low interest in the reviews and so ended up being replaced by more compelling content (the second add-on chapter, etc) and so we could keep to a reasonable # of pages.

So, I have some good material I want to put out and am planning on releasing. I have to finalize the location but I'll have to make a note and include a post here to announce it once it is online.

Short/sweet though:

- you can't use scaffolds with web flow
- you pretty much use web flow the same way you do in Spring itself, since you're on a Spring app
- you have to either go rogue and use the Spring MVC spring: and form: tags or create a few of your own (that's what I did in the chapter).

I'll try to get that content out in a month or so, I'm just cleaning up some other things right now.

Ken
8 years ago
Also, on line 52 of your spring config, the bean setter is setTblSysUserDetailDAO, so your setter name is invalid. The property should have a name of "tblSysUserDetailDAO" - that's why it can't understand this.

Best of luck continuing on your project. I'd definitely take time to match your properties to log errors - I do this all the time and whenever I hand code XML I pay the price ;)

IntelliJ, Netbeans or Springsource Tool Suite (eclipse with the Spring IDE plugins installed) should help you with CTRL-SPACE so that you are picking valid bean and field names.

Best,

Ken
8 years ago
The app is running from the target, not from the source code. So it will never find files in src/main/resources, because those have all been copied to target/classes and are in your class path.

Try:

<value>hibernate.cfg.xml</value>

or

<value>classpath:hibernate.cfg.xml</value>

Ken
8 years ago

Amol Parikh wrote:I am using Netbeans. Does this method apply to it as well.



Using Netbeans with Spring? Spring is tool and platform agnostic, it doesn't care. However, your reply seems to tell me that you want to experiment with reflection in standard Java.

If that's what you want, you can find samples in the Java Tutorial here:

http://docs.oracle.com/javase/tutorial/reflect/class/classNew.html

The whole section on reflection is really good.

Spring doesn't really make you do reflective calls-it does that for you, you give it instructions such as:



This assumes you have classes such as:



In other words, Spring, on startup, will instantiate Baz and Game, and set the game instance with the instance of Baz that it creates. That's using reflection behind the scenes.
Ken
8 years ago
Spring now has a scheduling annotation feature. You can either use Quartz or use Spring Scheduling.

You'd have to set up a Spring context - look into the ContextLoaderListener (google it, for an example) - you mount it in your web.xml, and it will load a Spring configuration that you point to.

For example, you could use this setup:

/ (web root)

-- WEB-INF
-- spring
--- applicationContext.xml

Then use the path:
/WEB-INF/spring/applicationContext.xml when configuring the ContextLoaderListener parameters.

Ok, once that is done (again, plenty on setting up this in web.xml on Google) you can set up beans to fire via Quartz or by Spring's scheduler options. See this page for details:

http://static.springsource.org/spring/docs/3.0.5.RELEASE/reference/scheduling.html

See 25.6 for all the details you need to use quartz. You'll need to import the Quartz jars, but beyond that, this may really do it for you:

25.6.3: here are two types of quartz jobs you can schedule - direct from the documentation above.



SO access to simple repeating jobs, CRON syntax support, using Quartz jobs.

It really is a nice feature of the framework.

You should also check out @Scheduled and @Async - you can annotate a method async and have it run outside of your thread. Pretty nifty for certain 'fire and forget' operations where normally you needed to set up JMS and a queue in the past.
8 years ago

Rahul Dayal Sharma wrote:Hi Ken,
I will check out that book, but i would like to know about the prerequisites for Spring and of course Roo



Spring:

Core:
- Solid Java OO development techniques - interface driven development
- Some knowledge of the concept of reflection and what it does
- A background in Java EE concepts such as transaction management and security
- Understanding of the proxy design pattern - Spring uses dynamic proxies to wrap beans with transaction, security, jmx, and other support

Web (MVC):
- Helps to have prior use of a model-view-controller patterned web framework such as Struts, but you can learn in in the context of Spring MVC
- Comfort with annotation-driven Spring bean configuration - Spring MVC is annotation-driven, so you'd use annotations such as @RequestMapping, @Controller, etc.
- Some web application server knowledge - how to deploy wars, for example
- Knowledge of a build tool such as Ant or Maven - both of which can be used to put together Spring builds

Spring DBMS support
- Knowledge of JDBC
- Knowledge of a database, such as PostreSQL, Oracle, Sybase, etc...
- Knowledge of how to connect to a database normally (connection settings such as username, password, server, JDBC URL, etc)
- for ORM such as JPA or Hibernate, you'll need to learn how those are programmed, but Spring can make it easier for you
- for JDBC, Spring has a fantastic tool called the JdbcTemplate that simplifies JDBC code to one or two lines plus a handler method - no more try catch code!

The same pattern is true for any technology Spring exposes. It helps to know it, to see examples natively in it, so that you can see how Spring approaches providing those services to you. And the manual for Spring itself - the Spring Framework Reference Guide - is really, really good. One of the best.

Spring Roo won't be as useful to you unless you know the above to some degree. In a way, it's a power tool, one that can make your life easier. Especially if you have a lot of repetitive tasks, or have to create a lot of projects in your organization and want to set some standards, it's great. But it needs some focus by the developers using it, or it will just be a code generation tool.

So, start w/Spring, but as you're learning Spring, try creating projects in Spring Roo that have the features you're researching. For example:

For JMS, go ahead and use jms setup to set up a JMS server inside of your app, then write JUnit integration tests to learn how to post messages and consume answers.

For JDBC, go ahead, set up a simple Roo project, and inject the dataSource into an integration test. Then create a JdbcTemplate instance (it takes the dataSource as a constructor) and play with it.

etc...

Hope this helps.

Ken

-
8 years ago
My quick answer - AJAXIZE the form post, and review the result. Come up with a JSON equivalent of an error list and convert it when received in your backend. There are probably built-in resources here for some of this. Roo includes a thin Spring Javascript livrary that wraps dojo and can convert form posts to ajax, but so does native Dojo and jQuery, etc.

So it could be (psuedo code here):

8 years ago
The Flex add-on has been in limbo for a long time. It is not lart of the regular distribution, and though it had good aims, it has noot been maintained.

I would consider using Spring Roo for the back tier of the app, installing mvc, and then installing Spring Flex Integration manually.

For other front ends, Roo 1.2.2 works with JSF and with GWT, using the web jsf setup or web gwt setup commands, but I have no experience practically speaking with either of those and Roo, beyond researching them for the book.

If you are doing mobile web apps, consider jQuery Mobile with Spring MVC and using @RooJson (json setup) to add the json encoders to the entity or a dto. Then you can write Spring MVC to expose the JSON string as a result using:

@RequestMapping(...)
public @ResponseBody String doSomething(..) {
...
Results.toJson... (i forget the method name Roo puts in there but once you annotat a Java class with @RooJson it will create an ITD (file ending in .aj) loke Foo_Roo_Json.aj with methods to encode/decode a single instance and a list.

You can also submit JSON to the controller using a String parameter and @RequestBody annotating that parameter.

Ken
8 years ago

sachin pachpute wrote:
What does is mean to a developer who is working on Spring3 MVC & hibernate with Eclipse IDE and does not know Roo? I have started developing application a month back and now came across this post.



It means that you'd have to adjust your coding a bit to work inside of a Roo platform. To wit:

- You'd need to use JPA 2, with a Hibernate provider, rather than Hibernate. Roo is a JPA platform. So you'd use EntityManager rather than SessionFactory & Session.
- You'd be using JSPX if you use the Spring Roo web application tier. Spring Roo really wants you to use that.

Beyond that, I'm beginning some EARLY work on a web mvclite add-on that would only use JSP tags and JSP pages, one-way scaffolding (generate but not sync) and removes all hints of client-side code and validation (only server-side).

I would like to see this through to a 1.0 version, and since my project is hosted on CloudBees as an open source project, I will be releasing it to everyone as research. I would at least try to do this and then show it to the Roo team, emphasizing that this should be a built-in choice so that we don't have to get Dojo + all the other heavy duty selections made for us initially.

Ken
8 years ago
Check out the Spring Remoting section of the Spring reference manual - I would recommend not using EJB here - you can use any number of lightweight protocols to expose your Spring beans, such as Hessian, Burlap, Spring's HttpInvoker, or RMI.

If this is internal, remoting should be faster than REST but REST is easier and may be fast enough, although that requires mounting a web mvc app in your back teir.

Another angle is to create a facade spring bean, mount the ejb in your 2nd app using the jee:jndi tag as a Spring bean, and make calls to it via this other Spring bean. Expose the new Spring bean with remoting, and gradually move methods into Spring, replacing the EJB with calls to Spring based APis.
Ken
8 years ago