Using Struts2 in NetBeans6.9 - struts2

Im newly using Struts2 now,but previously i used to work with Struts1.3.While using struts2 with netbeans6.9 IDE i'm facing problem.Actually i want to know what's the real difference between struts1&2 on implementation?.Is there any difference between them in the development?

Perhaps this thread will help: Struts 1.x vs Struts 2.x

Related

How to use ActionForm, ActionForward, DispatchAction, ActionMessages in Struts2

I am converting application from struts1 to struts2 so I need to use ActionForm, ActionForward, DispatchAction, ActionMessages.
How I can use that in struts 2?
If you convert an app from struts1 to struts2 then you don't need to use these classes because they belong to struts1, but if you want to use struts2-struts1-plugin then you can use them. Note that using this plugin is is not easy and requires some effort to configure such application. See Struts 1 Plugin.

Struts 1 or Struts 2 . Which one is advisable for web application development?

I am little bit confused to choose Struts 1 or Struts 2 for my new web application development assignment. Could any one suggest me which framework should I use for development from architecture point of view? What are the points I should take care of to choose the struts version before I go for development of the application?
Any help will be appreciated.
Hi I prefer struts 2 because,
Struts 1.x
In struts 1.x front controller is ActionServlet
In struts 1.x we have RequestProcessor class
In struts 1.x we have multiple tag libraries like html, logic, bean..etc
In struts 1.x the configuration fine name can be [any name].xml and we used to place in web-inf folder
In struts 1.x we have form beans and Action classes separately
In struts 1.x an Action class is a single ton class, so Action class object is not a thread safe, as a programmer we need to make it as thread safe by applying synchronization
In struts 1.x we have only jsp as a view technology
Struts 2.X
In 2.x front controller is FilterDispatcher
In 2.x we have Interceptors instead RequestProcessor
In 2.x we do not have multiple libraries, instead we have single library which includes all tags
In 2.x the configuration file must be struts.xml only and this must be in classes folder
In 2.x form bean, Action classes are combinedly given as Action class only, of course we can take separately if we want
In 2.x an Action class object will be created for each request, so it is by default thread safe, so we no need to take care about safety issues here
In 2.x we have support of multiple view technologies like velocity, Freemarker, jasper reports, jsp.
Since you have mentioned that it is going to be a new web-application,Just go with Struts2.Struts1 has already in EOL which means there will be no loner support for the Struts1.
Also Struts2 is a new and very flexible framework and will provide you a lot more control.Here are
Choose latest version of Struts2 to start work with (2.3.15.1)
If you are planning to write your service layer in Spring, you can use Struts2-spring plugin to let spring DI manage struts2 component for you.
Since you seems new to Struts2, i suggest to pay special attention to OGNL which is a core building block in struts2 and you will going to use it a lot in your Tags at UI.
Struts2 has a very flexible plug-able architecture which let you to create as well use many plugin which can save your time to build functionality from start.
Hope this might help you.Additionally You can review and look in to other MVC framework also
I also prefer going with Struts2 itself rather than Struts1 because Struts1 is old and its EOL has been announced on September 1, 2013 with the message "the Struts 1.x web framework has reached its end of life and is no longer officially supported."
[Source:- wikipedia.org]
So it is better to go with Struts2[i have been using version:-2.3.1.1 as I faced some "Dispatcher error"(jar files in the package were not compatible with each other) issue while using 2.3.16 version]
Hope this might help.
I've had a similar dilemma as you do, but instead of going with Struts, I've chosen Tapestry after some consideration.
Some of its awesome features are
Pages as POJOs
Really good dependency injection
Scalable
Easy to learn with lots of examples
much more...

Mixing JSF1.2 and JSF2

The legacy web app is using JSF1.2 with facelets. Due to the size of the app, upgrading it to JSF2 would take extensive effort. Is it possible to mix JSF1.2 and JSF2 in the same web app during the transition period?
I read this post: Mixing JSP and XHTML (Facelets) in JSF2 Project - possible?
but it seems to be related more to converting a JSP app to JSF2?
Thanks for any help.
Is it possible to mix JSF1.2 and JSF2 in the same web app during the transition period?
No.
You can mix JSP and Facelets in one web application, but you can definitely not mix different JSF impls/versions in the same web application. It would only result in class loading conflicts in all colors because multiple different versions of the very same classes are then present in the runtime classpath.
See also:
Migrating from JSF 1.2 to JSF 2.0

Struts2 workflow/webflow plugin

I want a workflow/webflow plugin that needs to be integrated with an existing Struts2 application.
I found Struts-workflow-extension but looking in its source code I realized it is entirely based on the Struts1 and have there is no support for this plugin since 2003.
Basically my requirement is to handle the entire workflow through configurations that could be done at runtime. Spring webflow is also an option but it's much of a learning curve depending on the deadline that I have to meet.
So is there any workflow/webflow extension that can be easily integrated with Struts2?
Any help will be highly appreciated. Thanks
You can try https://github.com/aleksandr-m/struts2-actionflow which seems to be more up to date.

Cannot create a session after the response has been committed - PrettyFaces MultiPageMessagesSupport on Glassfish4

I have a Java EE app where I use JSF2 + PrettyFaces + EBJ3 + Glassfish
I just recently updated to Glassfish4 which is the default Server implementation for Java EE 7 and I started getting issues with PrettyFaces.
I have configured on my faces-config.xml:
<lifecycle>
<phase-listener>com.ocpsoft.pretty.faces.event.MultiPageMessagesSupport</phase-listener>
</lifecycle>
to enable for Faces Messages to be passed around correctly and displayed on screen.
But since I upgraded from Glassfish3 to 4 I started getting this issue:
java.lang.IllegalStateException: Cannot create a session after the response has
been committed
...
at com.ocpsoft.pretty.faces.util.FacesMessagesUtils.saveMessages(FacesMe
ssagesUtils.java:56)
at com.ocpsoft.pretty.faces.event.MultiPageMessagesSupport.afterPhase(Mu
ltiPageMessagesSupport.java:66)
If I remove the listener from faces-config.xml none of the Faces messages are displayed on screen.
I am using PrettyFaces to have nice well formatted URLs to enhance SEO on my site. I wish I couldn't have to replace it or refactor my app to not use it since I already mapped a lot of the navigation flow using it. Does somebody know a better option for this scenario?
I really appreciate any suggestions. Thanks.
I don't recommend to use MultiPageMessagesSupport if you are deploying to a "modern" container with JSF 2.2 support. The MultiPageMessagesSupport phase listener has been developed for JSF 1.x. JSF 2.x added support for persisting messages across redirects. Just execute this code before redirecting:
FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true);

Resources