Discussions

Web tier: servlets, JSP, Web frameworks: Struts: Different eclipse projects for JSPs and actions?

  1. Hi! In our Struts application we would like to seperate the view from the controller aka building seperate eclipse projects for the JSPs and the actions. Does anyone know if this is possible and if it works how we could do this? Do we need two Strust projects or only one combinded with a normal java project? Where do we have to place the struts-config.xml? BTW, we use Eclipse 3.2 with Exadel Studio 4.0. Thanks! haefti
  2. If by actions you mean the struts action forms etc., these are generally considered to be part of the view in the MVC pattern. It is the servlet that plays the part of the controller, passing on the user's request to the appropriate business objects. If you separate out functionality like this separate projects are not necessary.
  3. Hi! First all of thanks for your answer.
    If by actions you mean the struts action forms etc., these are generally considered to be part of the view in the MVC pattern.
    No, I referred to the Struts Action classes.
    It is the servlet that plays the part of the controller, passing on the user's request to the appropriate business objects.
    If you separate out functionality like this separate projects are not necessary.
    I don't know if you really understood what I meant. I do know that the Action classes and the Action Servlet represent the controller logic. That is why I like to seperate the view (aka the JSPs) from the controller (aka the Action classes). I'd like to do this because I want to have the same web application functionality for different customers each with a different view so I can develop the controller logic in one eclipse project for all customers and let the JSPs be developed in seperate projects. (Of course the structure and file names in the view projects have to be the same.) To supply new WAR-files for every customer I would just have to change the build path entry for the corresponding view project in the controller project and export it. To sum it up, the goal is to have one project with Action classes (and Action forms) and n projects with JSPs. You think this is possible? Thanks! haefti
  4. Are you trying to create a product where the look and feel of the UI can be customized according to the cutsomer's wishes, but, the functionality remains the same? If yes, there are better ways to achieve this using a single set of JSPs. With regard to your question, you can use any number of Eclipse projects to organize code any way you want. As long as your build process is designed to accomodate the many projects, you should be okay. I still cannot think of a reason why you would want to do this though.
  5. Hi!
    Are you trying to create a product where the look and feel of the UI can be customized according to the cutsomer's wishes, but, the functionality remains the same?
    No. As I mentioned in the post before I'd like to produce several web applications containing the same controller logic but a different view. The web applications are supposed to be deployed on different machines. "Customer" in this case means, that we, as the developers, offer the web application to our customers. Several customers get the same web application with the same functionality but a personalized view. We could easily have one Struts project for customer#1 and anonther struts project for customer#2. Because all the actions in both projects would contain the same code it would be more clever to have one controller project and one view project for customer#1 and one view project for customer#2: controller + view#1 produces WAR-file for customer#1 controller + view#2 produces WAR-file for customer#2 No redundant code exists because the controller is used for every customer. Do you understand now?
    With regard to your question, you can use any number of Eclipse projects to organize code any way you want. As long as your build process is designed to accomodate the many projects, you should be okay. I still cannot think of a reason why you would want to do this though.
    Hopefully my explanations above could make my motivation a little bit clearer. How to organize eclipse projects in general is not the proplem but in this special case it would be interesting if anyone has experiences with it.
  6. why ??[ Go to top ]

    To answer your question, no I do not have any experience in carrying out builds where view (n) + controller = war(n) As I said in my earlier post, if all you are customizing is colors and images, there are better ways to do it. That being said, I would still keep everything in one project and use Ant to script the build that will do the work for me. Exporting jars/wars by hand seems ok for small apps/webapps but to build something that needs to be delivered to a customer, you would want some accountability in terms of what was built, when it was built etc.
  7. Re: why ??[ Go to top ]

    To answer your question, no I do not have any experience in carrying out builds where

    view (n) + controller = war(n)
    Okay.
    As I said in my earlier post, if all you are customizing is colors and images, there are better ways to do it.
    Which one? I'm thankfull for every suggestion. (You did understand that we want to provide different web applications with the same java core on different servers?)
    That being said, I would still keep everything in one project and use Ant to script the build that will do the work for me. Exporting jars/wars by hand seems ok for small apps/webapps but to build something that needs to be delivered to a customer, you would want some accountability in terms of what was built, when it was built etc.
    At the moment we host the stuff for the first customer so that's not the big problem right now. Of course there has to be an autmatic building process but that does not solve our problem. We just do not want to have the same bunch of Action classes in two (or more) different projects. Modifying classes and than copying them from one project to n others seems to me not like the most effective way, you know?
  8. It very much depends on how different the UI is. Given that the basic funtionality behind the UI is the same, it suggests that the customisation is limited to colours, logo, and maybe language. For colours etc., you might want to look at stylesheets or something like that. Different languages may be dealt with either by properties files and I18N or byreading from a database. An approach on these lines - if my assumption about your requirements is correct - should allow you to have only a single set of JSPs with a build file taking care of the different requirements for each customer's build
  9. It very much depends on how different the UI is.

    Given that the basic funtionality behind the UI is the same, it suggests that the customisation is limited to colours, logo, and maybe language.

    For colours etc., you might want to look at stylesheets or something like that.
    You're right but it seems like it could be more than changing some colors. For example, if one customer does not want some special data on the site it's pretty complicated solving this completely by CSS. Another thing is that the UIs are designed by our customers so we can not force them to work "together". ;-)
    Different languages may be dealt with either by properties files and I18N or byreading from a database.
    That's not the point, it is already implemented.
    An approach on these lines - if my assumption about your requirements is correct - should allow you to have only a single set of JSPs with a build file taking care of the different requirements for each customer's build
    From my point of view the UIs will be to different. I don't have much experience with build scripts but in a struts project we are forced to use the same JSPs (JSPs with the same name) otherwise the struts-config.xml wouldn't work. I don't know if there is a way to switch the JSPs and the struts-config.xml at the same time but maybe we'll have a try. Thanks! haefti
  10. you can have a struts config where the JSP names are placeholders and have ANT replace them at build time. Look at the replacetoken task. Looks like you need to spend some time with Ant and you should be good to go.
  11. you can have a struts config where the JSP names are placeholders and have ANT replace them at build time. Look at the replacetoken task.
    This sounds pretty good. Thanks a lot for the suggestion!
    Looks like you need to spend some time with Ant and you should be good to go.
    Yeah, looks like that. :-) Thanks for the help!