1 2 Previous Next 15 Replies Latest reply on Apr 16, 2007 4:33 AM by Alex Grönholm

    Seam enhanced EL expression fails in an Ajax4JSF tag

    Alex Grönholm Novice

      The tag

      <a4j:commandLink value="Previous" action="#{categorybean.setPage(0)}" />

      fails to render, saying:
      javax.el.ELException: Error Parsing: #{categorybean.setPage(0)}
       at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:125)
       at org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:146)
       at org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:190)
       at org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:68)
       at org.jboss.seam.ui.facelet.SeamExpressionFactory.createValueExpression(SeamExpressionFactory.java:105)
      ...
      

      However, the same renders just fine if I use <h:commandLink> instead.
      The declaration of the method is as follows:
      void setPage(int page);
      

      What am I doing wrong?

        • 1. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
          Pete Muir Master

          There is a known issue with using Seam EL enhancements inside facelets tags. I think that jboss-el in Seam 1.3 should fix this

          • 2. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
            Alex Grönholm Novice

            Ok, but meanwhile, I wanted to put up links so the user can jump to another page on the table without having to refresh the whole page. How can I possibly accomplish this? How can I tell the seam component which page I want to jump to?

            • 3. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
              Fernando Montaño Expert

              I had the same problem with Seam enhanced EL method expressions. I'm waiting the solution.

              But in the meantime I did something like:

              <a4j:commandLink value="Previous" action="#{categorybean.jumpPage}" >
               <a4j:actionparam name="page" value="0" assignTo="#{categorybean.page}"/>
              </a4j:commandLink>
              
              


              page must be an variable with its respective setter (void setPage(int v)), and jumpPage non-arg method (void jumpPage()).

              And it is working.

              HTH.



              • 5. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
                Alex Grönholm Novice

                Sorry but it still doesn't work.

                javax.el.ELException: /category.xhtml: Property 'jumpPage' not found on type org.javassist.tmp.java.lang.Object_$$_javassist_89
                 at com.sun.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:53)
                 at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
                 at com.sun.facelets.compiler.UILeaf.encodeAll(UILeaf.java:149)
                 at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
                

                It seems like it's trying to evaluate the contents of "action" as a value expression and not a method expression. Any ideas?

                • 6. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
                  Fernando Montaño Expert

                  Could you post some code to see it?

                  • 7. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
                    Alex Grönholm Novice

                    I don't know what code you want to see, but here's the bean code:

                    @Stateful
                    @Scope(ScopeType.SESSION)
                    @Name("categorybean")
                    public class CategoryBean implements CategoryLocal {
                    
                     private static final int PAGE_SIZE = 30;
                    
                     @In
                     private EntityManager db;
                    
                     @RequestParameter
                     private String id;
                    
                     private Category cat;
                     private Query entryQuery;
                     private int page = 0;
                    
                     public Category getCategory() {
                     if (cat == null)
                     cat = db.find(Category.class, Short.parseShort(id));
                     return cat;
                     }
                    
                     @SuppressWarnings("unchecked")
                     public List<Entry> getEntries() {
                     if (entryQuery == null) {
                     Session session = (Session) db.getDelegate();
                     entryQuery = session.createFilter(getCategory().getEntries(), "");
                     }
                    
                     entryQuery.setFirstResult(page * PAGE_SIZE).setMaxResults(30);
                     return entryQuery.list();
                     }
                    
                     public boolean isPreviousPageAvailable() {
                     return page > 0;
                     }
                    
                     public boolean isNextPageAvailable() {
                     return page * PAGE_SIZE < getCategory().getNumEntries() - 1;
                     }
                    
                     public void jumpPage() {
                     // Dummy method for jumping pages
                     }
                    
                     public void previousPage() {
                     page--;
                     }
                    
                     public void nextPage() {
                     page++;
                     }
                    
                     public int getPage() {
                     return page;
                     }
                    
                     public void setPage(int page) {
                     this.page = page;
                     }
                    
                     public int[] getPageNumbers() {
                     int[] pageNumbers = new int[getCategory().getNumEntries()];
                     for (int i = 0; i < getCategory().getNumEntries(); i++)
                     pageNumbers = i + 1;
                     return pageNumbers;
                     }
                    
                     @Remove @Destroy
                     public void destroy() {}
                    
                     }
                    

                    and the local interface:
                    @Local
                    public interface CategoryLocal {
                    
                     Category getCategory();
                    
                     List<Entry> getEntries();
                    
                     int[] getPageNumbers();
                    
                     void jumpPage();
                    
                     int getPage();
                    
                     void setPage(int page);
                    
                     boolean isPreviousPageAvailable();
                    
                     boolean isNextPageAvailable();
                    
                     void previousPage();
                    
                     void nextPage();
                    
                     void destroy();
                    
                    }
                    


                    • 8. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
                      Fernando Montaño Expert

                      Code you post shows the Bean, is it possible to see the view source (.xhtml).

                      BTW, I don't know what could be the reason for the last exception you post, but try to remove the <a4j:actionparam/> and check if you are getting the same error.

                      Another thing different of my code is that I was using "Integer" (for the page) not "int" for the variable...maybe this does not matter, but I'm not sure, if you like you can try it.


                      Regards,

                      • 9. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
                        Alex Grönholm Novice

                        Looks like I had some old libs in WEB-INF/lib/ that may have caused these problems. At least I'm getting all different error messages now =)

                        • 10. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
                          Alex Grönholm Novice

                          No, it still doesn't work. I made a real simple xhtml page:

                          <?xml version="1.0" encoding="utf-8"?>
                          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                          <html xmlns="http://www.w3.org/1999/xhtml"
                           xmlns:a4j="http//ajax4jsf.dev.java.net/ajax"
                           lang="en" xml:lang="en">
                          <head>
                          <title>Test</title>
                          </head>
                          <body>
                           <a4j:form>
                           <a4j:commandLink value="Test" action="#{categorybean.jumpPage}" />
                           </a4j:form>
                          </body>
                          </html>

                          I still get the error message:
                          /hello.xhtml: Property 'jumpPage' not found on type org.javassist.tmp.java.lang.Object_$$_javassist_7

                          It'd help if I could find so much as a single working app that used <a4j:commandLink>.

                          • 11. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
                            Fernando Montaño Expert

                            This is weird . But you can see the Booking Seam example which uses Ajax4JSF, and check what you have different.

                            By instance in that example you have aregister.xhtml page and you can change this part:

                            <h:commandButton id="register" value="Register" action="#{register.register}"/>
                            
                            


                            to this one:

                            
                            <a4j:commandLink id="register" value="Register" action="#{register.register}"/>
                            
                            


                            That should work.

                            I took a look that example before migrating my Seam app. to Ajax4JSF


                            HTH.


                            • 12. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
                              Alex Grönholm Novice

                              Ok, I've been busy trying to figure out WTF is wrong with this. According to my research, Ajax4JSF + Facelets = bust. I created a very simple page with one managed bean, no Seam involved. <a4j:commandLink> causes an error message if Facelets is involved, but works fine on the corresponding JSP page. If I change a4j:commandLink to h:commandLink, then even the facelets page renders fine.
                              You can download the test project here: http://paradoxx.dyndns.org/TestWeb.tar.gz
                              I tried several different versions of both Facelets and Ajax4JSF, to no avail. I have no idea what to do :(

                              • 13. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
                                Fernando Montaño Expert

                                 

                                "alexg79" wrote:
                                According to my research, Ajax4JSF + Facelets = bust.


                                I disagree with you here. Facelets is a great technology to build the view on JSF applications, And Ajax4JSF is another one to AJAXify a JSF application.

                                I know sometimes when something does not work like we want, we look for something to blame. I absolutely think this is not the case.

                                Well, I download your example and configure it to Tomcat 5.5, which I'm using. I saw you had your project configured for JBoss 4.2, but I didn't care about it because the simplicity of your example.

                                Using simple JSP page it worked fine.
                                Using Facelets I got the exception you post here before (property instead action method). This was weird the first time, but then I found the cause for the problem was a simple 's'.

                                I mean, you had this:

                                <html xmlns="http://www.w3.org/1999/xhtml"
                                 xmlns:a4j="http//ajax4jsf.dev.java.net/ajax"
                                 xmlns:h="http://java.sun.com/jsf/html"
                                 xmlns:f="http://java.sun.com/jsf/core"
                                 lang="en" xml:lang="en">
                                ...
                                


                                But, it should be:
                                <html xmlns="http://www.w3.org/1999/xhtml"
                                 xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
                                 xmlns:h="http://java.sun.com/jsf/html"
                                 xmlns:f="http://java.sun.com/jsf/core"
                                 lang="en" xml:lang="en">
                                ...
                                



                                Sorry, because I didn't see the error in the last code you post here. But sometimes to find this kind of errors one must have the code running.

                                So, take care with the xhtml namespaces next time ;-)

                                Regards.

                                • 14. Re: Seam enhanced EL expression fails in an Ajax4JSF tag
                                  Fernando Montaño Expert

                                  Oops, typo, the problem not only was an 's' it was namespace URL at all (https://).

                                  This sometimes happen ;-)

                                  1 2 Previous Next