1 2 Previous Next 24 Replies Latest reply on Jan 11, 2007 5:44 AM by theute Go to original post
      • 15. Re: Best way to learn
        agathon

         

        "thomas.heute@jboss.com" wrote:
        What you mention first looks like a weird bug in your application, not a flaw.


        This may be true, but there were no indications that this was the case; otherwise, we would have fixed it. How it "looks like a weird bug in [my] application", when you:

        a) Have not seen the bug
        b) Have not seen the source code
        c) Have no idea what environment MyFaces was running in

        is beyond me.

        "thomas.heute@jboss.com" wrote:
        "lack of control the developer has over the markup" is actually the best thing, as a developer i don't want to mess with markup, i want my designer to do this job. This is just a matter of components anyway and the components let the designer focus once on the way something has to be rendered.


        FYI, I wear both hats: designer and developer. In formatting a user interface you have several options: CSS, the standard components (which suffer from the "flaws" I mentioned previously), and creating custom components (not fun). Among these CSS is your best bet, but it is more limited, and has more varying levels of implementation among browsers than plain old HTML (although this is slowly changing).

        That said, I do agree with your point: when I put on my developer hat I just want to work with components. However, when I put on my designer hat, I want to be able to easily modify all the HTML that is produced. Balancing the requirements of developers verus those of designers is tricky business. Unfortunately, in my opinion, JSF leans too far towards the needs of developers while gimping designers.

        • 16. Re: Best way to learn
          agathon

           

          "thomas.heute@jboss.com" wrote:
          I wouldn't prevent users from gaining benefits of JSF for those reasons. JSF is by design more adapted to a portlet environment since it doesn't rely on the HTTP*Servlet*Request.


          I would just like to reiterate that I have had zero problems using Struts in a portlet environment. Maybe the design is more elegant, but this is really a non-issue if you're developing for the web.

          • 17. Re: Best way to learn
            danny_hon

            We are also looking at what is the best framework for creating portlets. We find some issues using Struts. If we use request.setAttribute(...) in an Action class, the variable is not visible in the JSP. The work around is to use request.getSession.setAttribute(...). This is not very elegant, and we have to remove the sessiono attribute later. In addition, the validation from a form is not working. Even though it does not accept the invalid values (which is good), it does not show the error from the JSP <html:errors /> tag. It seems like these 2 problems are related to the fact that variable set by request.setAttribute() is not visible by the forwarded JSP.

            We are using JBP 2.2.x + Struts-Bridge 1.0. Does anyone have the same problem? Any help is appreciated.

            • 18. Re: Best way to learn

               

              "Agathon" wrote:
              However, when I put on my designer hat, I want to be able to easily modify all the HTML that is produced. Balancing the requirements of developers verus those of designers is tricky business. Unfortunately, in my opinion, JSF leans too far towards the needs of developers while gimping designers.


              On the contrary, JSF relies heavily on CSS for the presentation layer. Yes, you cannot control the actual markup produced unless you create your own components, perhaps, but CSS allows you to control the rendering. That strict separation between developer in the jsf components and designer in CSS, I would think would be welcomed.

              My gripe with JSF, is that I dont know CSS all that well, but for a team of mixed dev/designers, I would think this would be the way to go.

              • 19. Re: Best way to learn
                agathon

                 

                "danny_hon" wrote:
                We are also looking at what is the best framework for creating portlets. We find some issues using Struts. If we use request.setAttribute(...) in an Action class, the variable is not visible in the JSP. The work around is to use request.getSession.setAttribute(...). This is not very elegant, and we have to remove the sessiono attribute later. In addition, the validation from a form is not working. Even though it does not accept the invalid values (which is good), it does not show the error from the JSP <html:errors /> tag. It seems like these 2 problems are related to the fact that variable set by request.setAttribute() is not visible by the forwarded JSP.

                We are using JBP 2.2.x + Struts-Bridge 1.0. Does anyone have the same problem? Any help is appreciated.


                Sorry about the late reply; I was very busy over the last little while. Perhaps I was a little over-zealous in stating there are "zero problems" using Struts in a Portlet context. This problem stems from the fact that Struts actions and the rendering of the resulting JSP are (usually) contained in two separate requests. To fix this you will need to extend the PortletRequestProcessor provided with the Struts Bridge. Here is an example:

                public class CustomPortletRequestProcessor extends PortletRequestProcessor {
                 public void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
                 HttpSession session = request.getSession();
                 ActionMessages errors = (ActionMessages)session.getAttribute(Globals.ERROR_KEY);
                 session.removeAttribute(Globals.ERROR_KEY);
                
                 request.setAttribute(Globals.ERROR_KEY, errors);
                
                 super.process(request, response);
                
                 errors = (ActionMessages)request.getAttribute(Globals.ERROR_KEY);
                
                 if (errors != null && errors.isAccessed()) {
                 request.removeAttribute(Globals.ERROR_KEY);
                 } else {
                 session.setAttribute(Globals.ERROR_KEY, errors);
                 }
                 }
                }
                


                The dual request is also a problem if you want to keep your Hibernate session (if you're using Hibernate) open for both requests (action and render). We haven't found a solution to this problem and are presently using a workaround; using tag libraries to load some objects/collections in the view.

                • 20. Re: Best way to learn
                  danny_hon

                  I found out what's wrong with the setAttribute. It was because I missed the struts-portlet-config.xml file. Once I specified the attribute names in that file, the request.setAttribute(...) works.

                  However, the error handling is still not working. In the ActionForm's validate() method, I have something like this:

                  errors = new ActionErrors();
                  errors.add(ActionMessages.GLOBAL_MESSAGE,
                  new ActionMessage("error.invalidValue"));
                  ....
                  return errors

                  The struts-bridge documentation says this is automatically handled by the framework, but the JSP <html:errors /> does not show anything. I will try your CustomRequestProcessor to see what happen.

                  • 21. Re: Best way to learn
                    danny_hon

                    The CustomPortletRequestProcessor does work. Thanks a million!

                    • 22. Re: Best way to learn
                      agathon

                      Your reply inspired me to look at the struts-portlet-config.xml file again; initially I thought it was useless, since it didn't seem to do anything. The following configuration will allow messages and errors to be injected into the render request context, without having to make use of the CustomPortletRequestProcessor:

                      <?xml version="1.0" encoding="UTF-8"?>
                      <config>
                       <render-context>
                       <attribute name="org.apache.struts.action.ERROR" />
                       <attribute name="org.apache.struts.action.ACTION_MESSAGE" />
                       <attribute name="org.apache.struts.action.MESSAGE" />
                       </render-context>
                      </config>
                      


                      Enjoy!

                      • 23. Re: Best way to learn

                        This seems to be a general problem with any request attribute you set. The attribute is not visible to the JSP view page.

                        Adding any attribute name you use to the struts-portlet-config.xml does seem to make it work, but this isn't a very good solution if you're trying to port an existing Struts application which may be using request attributes everywhere. Does anyone have a solution to this problem? The sample struts application on the JBoss web site seems to carefully avoid ever using request attributes, but it seems like standard thing to do.

                        Thanks.


                        • 24. Re: Best way to learn
                          theute

                          Agathon explained very well the problem.

                          On an action phase you get 2 requests, the request attributes don't survive the first request. We actually have the same problem on the JSF-bridge, Stan fixed the problem on the JSF bridge of MyFaces.

                          Maybe you could push this problem to the Struts bridge developers ?

                          The last option if it can't be fixed in the Struts bridge would be to customize the portal to do everything in one request but it would bring another kind of troubles

                          1 2 Previous Next