10 Replies Latest reply on Jan 13, 2009 9:22 PM by vgriffin

    simpleTogglePanel onexpand, oncollapse

      I had hoped to use these to notify my application that the panel was being expanded or collapsed. That doesn't seem to be what they do. It seems like they are both called when the panel is expanded or collapsed. I can't figure out what they do from the documentation which reads:

      onexpand:
      Event must occurs on befor panel expanded

      oncollapse:
      Event must occurs on befor panel collapsed

      The only other information is that the expression must evaluate to a String.

      What do these properties do?

      I just downloaded 3.3.0.CR3 to see if the documentation had changed.

        • 1. Re: simpleTogglePanel onexpand, oncollapse
          nbelaevski

          Hello,

          Maybe example will help:

          <h:form>
           <rich:simpleTogglePanel onexpand="alert('expand')" oncollapse="alert('collapse')" switchType="server">
           Panel
           </rich:simpleTogglePanel>
           <rich:simpleTogglePanel onexpand="alert('expand')" oncollapse="alert('collapse')" switchType="ajax">
           Panel
           </rich:simpleTogglePanel>
           <rich:simpleTogglePanel onexpand="alert('expand')" oncollapse="alert('collapse')" switchType="client">
           Panel
           </rich:simpleTogglePanel>
          </h:form>
          ?

          • 2. Re: simpleTogglePanel onexpand, oncollapse

            No. That doesn't help. I can write something that gets invoked and had done so before posting my question.

            I want to know ehat it actually does and when it is supposed to be called. When I had stuff getting called, both actions were called when I caused an expand and when I caused a collapse. They were called in the same order regardless of which action occurred.

            I want to know what the cryptic descriptions mean.

            • 3. Re: simpleTogglePanel onexpand, oncollapse
              nbelaevski

              These client event handlers are invoked before panel is being switched to opposite state. I can not reproduce behavior you're describing; for me only one event is fired, but not two. Please post page code and version information.

              • 4. Re: simpleTogglePanel onexpand, oncollapse

                It's a Seam application, and I'm using the 2.1.1.CR1 version of Seam with new versions of RichFaces. I tried using both 3.2 GA and 3.3.0.CR3. It's in a pretty big project and I've ripped the code out because I couldn't get it to work.

                The xhtml code was similar to:

                <rich:simpleTogglePanel id="stp1" onexpand="#{tblHome.expanding}"
                oncollapse="#{tblHome.collapsing}" opened="#{tblHome.stp1open}"
                switchType="ajax">

                panel stuff

                </rich:simpleTogglePanel>

                In tblHome, I had:

                private boolean stp1open = false;

                getter/setter for stp1open

                Initially, I had:

                public void expanding()
                {
                System.out.println("expanding");
                }

                and

                public void collapsing()
                {
                System.out.println("collapsing");
                }

                It didn't like that. It said it needed to find pro0perties so I changed to:

                public void String getExpanding()
                {
                System.out.println("getExpanding");
                return "":
                }

                public void setExpanding(String str)
                {
                System.out.println("setExpanding " + str);
                return;
                }

                and similar collapsing methods.

                I never had more code than that in any of the expanding or collapsing methods because I was just trying to figure out what they did.

                Whenever I toggled stp1, either direction, I got a call to each getter. I never got a call to the setter.

                • 5. Re: simpleTogglePanel onexpand, oncollapse
                  nbelaevski

                  Well, setters should not be called. onexpand/oncollapse are client-side events, like onclick, onmouseover, etc. Getters are called because event handlers code is output to the client.
                  Use action/actionListener attributes for server-side code.

                  • 6. Re: simpleTogglePanel onexpand, oncollapse

                    The documentation should clearly state what is available on the client and on the server side. Perhaps another column could be added to the properties table.

                    What are the implications of the value that gets retrieved from the getter? How is any returned value used? You say it is "output to the client". What does the client look for?

                    • 7. Re: simpleTogglePanel onexpand, oncollapse
                      nbelaevski

                       

                      "vgriffin" wrote:
                      The documentation should clearly state what is available on the client and on the server side. Perhaps another column could be added to the properties table.

                      Documentation team has been notified about the problem.

                      "vgriffin" wrote:
                      What are the implications of the value that gets retrieved from the getter? How is any returned value used? You say it is "output to the client". What does the client look for?


                      onexpand/oncollapse are client-side events. Value of these attribute is interpreted by component as Javascript code which is executed when panel expands/collapses. Try my code example and you'll see how it's working.

                      • 8. Re: simpleTogglePanel onexpand, oncollapse

                        In other words, the getter would return a snippet of HTML script to be executed when the event occurs.

                        It also seems like server-side code can track expand and collapse activity using getter and setter calls to the value used to control the opened property.

                        • 9. Re: simpleTogglePanel onexpand, oncollapse
                          nbelaevski

                           

                          "vgriffin" wrote:
                          In other words, the getter would return a snippet of HTML script to be executed when the event occurs.

                          Exactly.
                          "vgriffin" wrote:
                          It also seems like server-side code can track expand and collapse activity using getter and setter calls to the value used to control the opened property.

                          Right, this is another possible way to track (and control) panel transitions.

                          • 10. Re: simpleTogglePanel onexpand, oncollapse

                            Thanks for taking the time to help with this.