5 Replies Latest reply on Feb 15, 2010 5:08 PM by bossy

    Unspecified error on s:button

    bossy

      Hello,


      I came across some rather strange behaviour of tag s:button.
      I have an onbeforeunload event on my page that asks the user whether to continue or not with certain actions. The problem I have is this: if the user clicks on a s:button element and selects to stay on the current page an “Unspecified error” appears, although it does not seem to be having any effect on the result. The same action with s:link works fine.

      Below is a test page that demonstrates this.




      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
      <f:view contentType="text/html" 
              xmlns="http://www.w3.org/1999/xhtml" 
              xmlns:ui="http://java.sun.com/jsf/facelets" 
              xmlns:h="http://java.sun.com/jsf/html" 
              xmlns:f="http://java.sun.com/jsf/core" 
              xmlns:a="http://richfaces.org/a4j" 
              xmlns:rich="http://richfaces.org/rich" 
              xmlns:s="http://jboss.com/products/seam/taglib"> 
              <html > 
                      <head> 
                              <script type="text/javascript" event="onbeforeunload" for="window"> 
                                              event.returnValue= 'You have unsaved changes' ; 
                              </script> 
                          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
                          <title>Test</title> 
                          <link rel="shortcut icon" href="#{request.contextPath}/favicon.ico"/> 
                          <a:loadStyle src="/stylesheet/theme.css"/> 
                          <ui:insert name="head"/> 
                      </head> 
              
                      <body onunload=""> 
                        <div class="body" >                
                            <s:button  id="homeB" value="Home" propagation="end" 
                                       view="/home.xhtml"  rendered="true"/>                      
                            <s:link id="homeL"    value="Home" propagation="end" 
                                       view="/home.xhtml"  rendered="true"/> 
                        </div>        
                      </body> 
              </html> 
      </f:view> 






      I'm using seam 2.1.1.GA and the application runs in IE6.


      Does anybody have an idea what might be causing this? Or is it a bug?


      Thanks.


        • 1. Re: Unspecified error on s:button
          asookazian

          Never heard/seen that but it sounds like it could be a bug.  Try it in FF.

          • 2. Re: Unspecified error on s:button
            bossy

            FF does not catch that event. It might be IE specific.


            I just tried it with IE 8 and exactly the same thing happens.


            Here's the message I get:




            Webpage error details
            
            Message: Unspecified error.
            Line: 14
            Char: 1
            Code: 0
            URI: http://localhost:8080/MYTest/Test.seam




            Any ideas, anyone?

            • 3. Re: Unspecified error on s:button
              cash1981

              Do your self a favour and start using JQuery. It is dead easy! If I can use it, so can you. They have a document.ready handler which supports all browsers.
              For more information see jquery.com

              • 4. Re: Unspecified error on s:button
                bossy

                Thanks, but jquery does not seem to support onbeforeunload event.
                Besides, the problem I came across is not with the event itself or how it's handled, but with the s:button element.


                So, my question still remains: why does s:button behave differently than s:link and causes this unspecified error.


                Thanks.

                • 5. Re: Unspecified error on s:button
                  bossy

                  If anyone's interested - I created a jira issue: JBSEAM-4544