I'm a Grails developer and I started development on Liferay 2 months ago.
I believe that if I can use Grails on Liferay I will increase my productivity by 2.
So here is my questions :
- What plugins to use to develop Liferay portlets ? I used some grails plugins but I got an error when generating portlet.xml.
- How can I configure the Grails dispatcher to work with Liferay. For example : to dispatch urls like this /web/guest/test?myportletId_WAR_aname_action=/user/show/1&myportletId_WAR_aname_windowstate=exclusive... to usercontroller and invoke show action ?
- How to get actionRequest, ActionResponse when invoking the action ?
Regards
As long as you consider the portlet as a particular view into your app it should definitely be possible. You could do it using a simple spec Java portlet that pulls information out of your main project, or look at the current Spring MVC Portlet and Groovy Portlet to see if those could be shortcuts for your implementation. I have worked with both (albeit not in the context of a Grails project) and can happily report that they work well with stock Liferay.
I'm reasonably sure that you can't create a portlet using Grails. You can of course write portlets in Groovy using GORM for data access. GSP isn't currently available outside of Grails so you might have to live with JSP for the views.
I've found that using the portlet support in spring MVC makes your life a little bit easier than raw portlets.
Good luck
Look for discussion of com.liferay.util.bridges.wai.WAIPortlet . I've taken little Grails apps that I've built, dropped them in the hot deploy directory on a generic Liferay 6.06 install as an experiment, and presto, they show up as portlets! I guess Liferay cooks up generic portlet.xml etc. for them. They aren't beautiful, nor are they tied into Liferay's Services API or database, but they run as a portlet, and of course you can also find them where they should be as stand-alone webapps. Fun!
Related
I have to convert a WebSphere portal application to a standard web application which can be deployed to WebSphere itself for now (and to JBoss later).
How can I find what built-in portal features are being used?
I have full code access. Are there any tools for this? What are the things I should consider?
Depends on how the application has been developed and which version of the portlet spec your application was built against.
If we take the case of porting a single portlet to a standard J2EE where the latest portlet spec is used the application might be using more modern practices e.g. be using resourceURLs and Ajax calls from JS to communicate with the backend.
This is the best case scenario, where you can take the JSP remove the portlet specific stuff e.g. the context roots and portlet name spaces. Then convert your resourceURLs into servlets by creating servlets which either call the same service methods or depending on how the code was written taken the code straight for the serveResource methods in the Portlet class.
Now worst case scenario for porting, this is where the portlet makes heavy use of actionURLs and other portal features which are very specific to the portlet spec. I'd guess that the best way of going about porting these is to try emulate the behavior of the portlet. You could try to hold all of your state information on the backend like a portlet does and replace these actionURLs/renderURLs with JSPs/servlets appropriately while having some object on the backend which stores the current state of the page for each user.
Hope this helps, more information on your project would obviously make it easier to help.
In regards to finding out what portlet specific features have been used look at the portlet class' imports and the tags used in the JSP along with the portlet.xml
I am a new web developer who is struggling to even set up local development environment with Eclipse. My goal is to eventually put my idea into a cool website that could be hosted on 64MB private JVM Tomcat 6 server (here).
I tried everything I could last 4 days reading bunch of tutorial sites and came up with an Eclipse project which could be downloaded. download.
I am overwhelmed with integrating so many frameworks (I wasn't an open source guy before), I feel that I'm stuck. Following are some questions I have.
How come when I run above project on Tomcat 6 server on local machine, I have to access it with "http://localhost/richfaces-tomcat6/" I want to be able to access it with "http://localhost/Namo/". Because "Namo" is going to be my website name.
How come "http://localhost/richfaces-tomcat6/index.xhtml" is not showing the inputText at all?
How come I cannot use "#Named" annotation for the managed beans? Instead I have to use "#ManagedBean". I read some where that #ManagedBean is really for the legacy system. Does this matter?
I am trying to code in JSF 2 with a bit of Ajax features on the site. I read some where Richfaces is useful. Am I even on the right track with setting these up?
I know I am asking a lot of questions. I am so ready to have something set up locally and hit the books for JSF but I can't even get started on it which is very frustrating. I would really appreciate it if somebody could help me or guide me to right direction.
How come when I run above project on Tomcat 6 server on local machine, I have to access it with "http://localhost/richfaces-tomcat6/" I want to be able to access it with "http://localhost/Namo/". Because "Namo" is going to be my website name.
The context path defaults to the Eclipse project name. You should have edited the context path in one of the last steps of the Eclipse project creation wizard. You can always edit it afterwards in the Web Project Settings section of the project's properties (rightclick project and choose Properties).
How come "http://localhost/richfaces-tomcat6/index.xhtml" is not showing the inputText at all?
Apparenty the request URL did not match the URL pattern of the FacesServlet as definied in web.xml. The given URL expects it to be mapped on an <url-pattern> of *.xhtml. Eclipse defaults to /faces/* and/or *.jsf and would require you to open the page by either http://localhost/richfaces-tomcat6/faces/index.xhtml or http://localhost/richfaces-tomcat6/index.jsf. But mapping the FacesServlet on *.xhtml is much better.
How come I cannot use "#Named" annotation for the managed beans? Instead I have to use "#ManagedBean". I read some where that #ManagedBean is really for the legacy system. Does this matter?
The #Named annotation is part of CDI which is part of Java EE 6. Tomcat is however a simple JSP/Servlet container and not a full fledged Java EE container. You'd either need to install CDI yourself if you want to use it on Tomcat, or to replace Tomcat by a fuller fledged Java EE container, such as Glassfish 3 or JBoss AS. See also the Weld documentation (Weld is the codename of the CDI reference implementation). Note that you don't necessarily need CDI to get JSF to run. Using #ManagedBean ought to be sufficient for a simple web application.
I am trying to code in JSF 2 with a bit of Ajax features on the site. I read some where Richfaces is useful. Am I even on the right track with setting these up?
JSF2 already supports Ajax out the box with the <f:ajax> tag. RichFaces is just a component library which offers more enhanced components and skinnability support on top of the standard component set. See also Communication in JSF 2.0.
1, 2 JSF 2.0 tutorial with eclipse tomcat
3 #ManagedBean makes sense for applications that use JSF but do not use JSR 299
4 yes you can do some cool stuff using RF, also jsf 2.0 has support of <f:ajax> so without RF using default implementation you could also do the AJAX stuff
You have severe memory constraints, so I'd better recommend to look at lightweight templating engines like Velocity or Freemarker for your pages and MVC frameworks like Struts/Struts 2 or Spring MVC.
I'm currently using Java & Spring (MVC) to create a webapp, and I'm considering moving to Grails. I'd appreciate feedback/insight on the following:
I have multiple application contexts in the current Java/Spring webapp that I load through the web.xml ContextLoaderListener; is it possible to have multiple application contexts in Grails? If, yes, how?
This webapp extensively uses a CXF restful web service and the current Java/Spring webapp uses the bundled CXF HTTP client. Can I continue to use the (Java) CXF HTTP Client in Grails?
I implemented Spring Security using a custom implementation of UserDetails and UserDetailsService, can I re-use these implementations in Grails "as is" or must I re-implement them?
There is an instance where I've relied on Spring's jdbc template (rather than the available ORM) and an additional data source I defined in app context, can I re-use this in Grails?
I plan on using Maven as the project management tool; are there any issues of using Maven with Grails where there is a combination of groovy and java?
Edit:
I'm considering moving to Grails to make the development of the web component of the webapp "faster," a la Ruby-on-Rails. Also, I'm considering Grails rather than say Ruby-on-Rails, because I want to continue to use the JVM and I've dabbled with Grails in the past and it was fairly easy to pick-up and use.
Probably. Grails uses a sub-class of Spring's ContextLoaderListener class which it configures in the web.xml file. I can answer more precisely if you let me know how you do it with Spring MVC.
Yes. You might even be interested in the CXF plugin, although I can't vouch for it:
http://grails.org/plugin/cxf
You should be able to use them as-is. However, you might want to check whether this is easily done with the Spring Security plugin. I believe it is, but you'll be able to get a definitive answer from Burt Beckwith, the author of the plugin.
Yes. You can also get hold of the Hibernate session factory to do raw Hibernate stuff. GORM can also work with multiple data sources:
http://grails.org/plugin/datasources
Another Burt Beckwith one :)
It depends on what you mean by "a combination of Groovy and Java". You can build Grails projects with Maven, but the integration isn't entirely smooth. If you have Java and Groovy in your Grails project, then that's taken care of automatically.
In response to Bozho, I use standard Grails services + GORM and wouldn't do it any other way. Note that if you use Java for services and the domain model, you won't have automatic reloading of services. You also lose the benefits of expressiveness and conciseness that Groovy bring.
If you want, you can use static types in Grails services to make it easier for your IDE to provide code completion. It can also give you hints on properties and methods it doesn't recognise (which would corresponding to Java compilation errors). That said, even if you use static types, Groovy can't do type checks at compilation time. You'll only find out about them at runtime.
You can do all these things in grails. It supports all existing Java classes and spring configurations (grails is built ontop of spring mvc)
However, I really wouldn't recommend moving the whole application to grails. You can perhaps move only the web layer, if you have web developers that are not java experts.
The service layer, the data access, etc, better remain pure Java. That is, only your web controllers - the components that gather the user input, handle http requests and sessions, should use grails. The rest - the stateless service classes and your domain model would better be Java. That's my opinion, but I have already some experience with grails, and static typing in the service layer will save you much trouble.
2) Yes you can use CXF as is. There is a nice layer on top of CXF called GroovyWS. I have only used it for consuming SOAP services, but maybe it has something for REST as well. It's really easy to use.
For consuming REST services I have used HTTP Builder
4) Yes. You can continue to use e.g. spring config for configuring the datasource, or any other way you do it today. Multiple datasources is no problem.
5) I have recently tried using Grails (1.2.1) with Maven. It works, but there has been some issues with both Maven and Grails trying to do dependency management. The documentation is maybe the worst part. I haven't tried upgrading to 1.3 yet because of some major Maven-related JIRAs, but 1.3.2 is right around the corner, and those issues have now been resolved :) There will also be a 1.3.2 maven archetype. Looking forward to that. "Deployment and resolution of plugins from Maven repositories" is one of the new features of Grails 1.3, so things are probably better. Roadmap for 1.3.2 says release today, but there are 8 issues left at time speaking, so my guess would be tomorrow, the Grails releases are usually on time. If you can wait for that, you will probably save yourself some trouble.
If you are looking for rapid application development but aren't otherwise particularly enthused about groovy, you should look into spring-roo. It offers the same kind of RAD functionality, but builds a completely standard java + ORM + spring-mvc app (which has no actual dependencies (runtime or compile) on roo). It's definitely not as mature as grails, but you may find that it better suits your existing experience with statically typed java code and existing ORM, etc. I've only done a couple of small pet projects in roo, but I've been very impressed so far, particularly with how easy it is to customize the generated code and move back and forth between written and generated code. The initial tutorial is very rapid and quite revealing.
I am trying to implement a web application(university project) in java using the following Frameworks
Spring Dependency Injection
Spring AOP (Logging and Transaction Management)
Spring DAO
JDBC or HIBERNATE
Spring MVC
Log4J
I create a new Web Application in Netbeans and it gives me a bunch of Files and folders by default.
Could anyone explain me what are the files ?
Where shall i put the code for the data access layer and business Logic?
Or where can i found a basic tutorial to get started(with data access layer, business layer and possibly code example)?
Thanks
One area in which NetBeans is very good is the online documentation and tutorials so leverage them:
Introduction to the Spring Framework
Developing a Spring Framework MVC application step-by-step using NetBeans and GlassFish
Using Hibernate in a Web Application
etc etc
That is a ton of Java frameworks for a Web Dev course at a university. My advice would be to start small, because you don't need all of those libraries to get a working web application.
As you found, Netbeans is doing a lot of work for you that you really need to know to be effective. Do a simple JSP or Java Servlet tutorial to get something up and running quickly from scratch on a lightweight app server like Jetty or Tomcat.
Also, please take a look at what Model View Controller architecture is prior to diving into Hibernate or SpringMVC. This is a critical step!
It would be good to list the files that you got, but I think I can guess:
WEB-INF/classes is where your compiled .java code will go. Everything should be in packages, so the directory and package structures should match. Your Spring XML and Hibernate .hbm.xml configuration files will go here as well, because that directory is automatically in the CLASSPATH of your web context.
WEB-INF/lib is where your 3rd party .jar files go. All the Spring and Hibernate JARs, plus all their dependencies, belong here.
The WEB-INF/web.xml is where you'll map in the Spring front controller/dispatcher servlet, the context loader listener, etc.
I don't know what others you got. If you list others, I'll try to explain.
Here is Netbeans web application + hibernate tutorial.
http://netbeans.org/kb/docs/web/hibernate-webapp.html
code for business and data access would go under
your project name/Source Packages/
Thanks for your input, Drew.
I'm working on a Capstone project and we are thinking about using Netbeans for our Web-based project but were unsure about how difficult it would be to make the Web Based application in a relatively short amount of time. The application is for a College Testing Center and the application will track testing information and data for testing personnel and instructors at our college. I was going to try and follow a few tutorials here on the Netbeans site.
Thanks for your time.
PHP and HTML5 Learning Trail with Netbeans..
Here's a video as well.
Youtube Simple Web App instruction video.
I plan to use Wicket to build a web site with database storage. I haven't used Wicket before. Is there any sample framework I can start from?
Well the Wicket site has more examples than you can shake a widget at.
Remember that Wicket is just a user-interface framework, it has nothing to say about things like database access. You'll need to look elsewhere for that (JDBC, Hibernate, JPA, etc)
If you are considering deploying to Google App Engine, I am working on a template project for Wicket applications. Visit http://code.google.com/p/wicket-gae-template/ and checkout from the Subversion trunk. It's a re-implementation of the App Engine "Guestbook" demo project, using Wicket rather than JSP. It also uses Maven for the build, JDO for persistence, Google Guice for dependency injection, and classes to support easy unit testing. Documentation on the site is nonexistent right now, so let the source code be your guide.
You can take a look at my simple CRUD example with wicket, db4o and guice. But keep in mind as skaffman pointed out: "Remember that Wicket is just a user-interface framework" (wicket is a nice one!)
Nevertheless in my post I listed some projects which can be helpful if you want to use wicket with a persistence solution:
wicketopia
databinder
wicketrad
Wicket-Iolite
antilia
wicket-phonebook
pure hibernate
wicket-grails plugin
If you would like to use guice or spring with wicket then probably these archetypes could help you to get started.
If you like building fancy apps take a look at this page.