3 Replies Latest reply: Nov 20, 2003 1:38 PM by 4996 RSS

    10g: Data Binding in event handlers?

    4996
      I'm trying to use data binding in my event handlers so that I can have a definitive source for the Strings that name things like this. I can see that the page is getting generated with the proper names on the elements in the page, but I always get an UnhandledEventException when I trigger the event. The idea is something like this:
      ...
              <submitButton text="Refresh" event="${ pageBean.controlRefreshEventName }" >
              </submitButton>
              <submitButton text="Hide Controls" event="${ pageBean.controlHideEventName }" >
              </submitButton>
      ...
      
          <handlers>
              <event name="${ pageBean.controlRefreshEventName }">
                  <method class="com.avega.portlets.view.EventHandler"
                          method="handleControlFormSubmit"/>
              </event>
              <event name="${ pageBean.controlHideEventName }">
                  <method class="com.avega.portlets.view.EventHandler"
                          method="handleControlFormSubmit"/>
              </event>
          </handlers>
      
      ...
      Now in my EventHandler I would be able to use the getXXXName methods when checking for which submit button was hit. Except I'm getting an exception instead.

      (BTW, I only have the two event tags because I wasn't sure how to concatenate the el expressions with a space...)
        • 1. Re: 10g: Data Binding in event handlers?
          4996
          Whoops! I see the problem -- the <handlers> tag is outside the <dataScope> tag, so the bean is not visible there. If I want to centralize the event names, I'll have to make them available on something that can be seen from the <handlers> tag, like the httpSession. I am surprised, however, that I didn't get some kind of exception.
          • 2. Re: 10g: Data Binding in event handlers?
            55663
            Do you get any warnings or anything during compile that
            it couldn't find the bean?
            • 3. Re: 10g: Data Binding in event handlers?
              4996
              No, there's no indication that anything is wrong until I cause the event and get the UnhandledEventException.

              However, I did the an experiment with the following tags, the first in a plain JSP, the second in a UIX page, and it seems that this is the normal way of handling a non-existant bean reference. Both cases printed 'text' in the page and did not complain that 'noBean' didn't exist. It seems you get an error when you reference a non-existant property on an existing bean, but no error if the bean itself doesn't exist. Anyway, UIX doesn't appear to be any different from JSP in this regard.
              <c:out value="${ noBean.noProperty } text" />
              
              <styledText text="${ noBean.noProperty } text" />