Uploaded image for project: 'Cocoon (Retired)'
  1. Cocoon (Retired)
  2. COCOON-1916

viewData is undefined in event handler when event is triggered outside showForm/sendPageAndWait

    XMLWordPrintableJSON

Details

  • Bug
  • Status: Closed
  • Minor
  • Resolution: Fixed
  • 2.1.8, 2.1.9, 2.1.10
  • 2.1.10, 2.2
  • Blocks: Forms
  • None
  • Normal

Description

When calling a java script snippet defined in the form description file, viewData is passed in the context as long as viewData is available from the objectModel and is not null. This makes it difficult to reliably use viewData in the snippet. Consider the case where you create a form and then dynamically assign some values to some widgets before actually showing the form. This results in value-changed events to be fired with viewData undefined in the context of the listener. Then using viewData in the snippet results in a reference error. If the event is fired from a sendPageAndWait context, viewData is neatly passed.
The problem is how to distinguish this in the event handler. It would be better to always pass viewData be it a null value some times. Then a simple test viewData == null could be used in the event handler. Note that viewData is also null when sendPageAndWait is called with only one parameter.

This problem occurs on line 69 in o.a.c.forms.event.impl.JavaScriptWidgetListener.java.
Is this a bug or is there some intentional use?

Attachments

Activity

People

cziegeler Carsten Ziegeler
rberens@osirion.nl Rob Berens
Votes:
0 Vote for this issue
Watchers:
0 Start watching this issue

Dates

Created:
Updated:
Resolved: