Hi,
I've some component inside a ComponentXML like this:
Now, I'd like to add a click event to the SaveViewButton to call custom java code. Since there are currently no other options, I try it programmatically.
Since the PickerIcon is not a Canvas, Canvas.getById() does not work here.
Instead, I try to obtain the DynamicForm by Canvas.getById(), then its DynamicForm fields and from there the PickerIcon like this:
In prodcution, the editIcon.getHandlerCount() pops up saying "HandlerCount: 0".
In addition, the onFormItemClick is never invoked when clicking on the icon (no popup).
Maybe this is a similar problem as described here: http://forums.smartclient.com/showthread.php?t=26343
except that this time, the widgeds could not be replaced by their global counterparts and the global ones are somehow shadowed by the "anonymous" ones?
By inspecting the FormItemIcon/PickerIcon using Firefox, I see this (which weakens the assumption above):
When trying to debug it in dev mode, the following uncatched exception (logged via)
is raised while invoking dynamicForm.getFields() or dynamicForm.getField("ViewsFormSelectItem2"):
So, how to register a listener with the FormItemIcon?
FF 20.0.1 & Version 26.0.1410.64 m
v8.3p_2013-04-28/PowerEdition Deployment (built 2013-04-28)
Thanks,
fatzopilot
I've some component inside a ComponentXML like this:
Code:
... <DynamicForm ID="ViewsForm"> <fields> <SelectItem ID="ViewsFormSelectItem" width="240"> <title><fmt:message key='tabBar_Views' /></title> <name>ViewsFormSelectItem2</name> <icons> <PickerIcon ID="EditViewButton" width="16" height="16"> <src>[SKIN]/actions/edit.png</src> <name>EditViewButton2</name> </PickerIcon> ...
Since the PickerIcon is not a Canvas, Canvas.getById() does not work here.
Instead, I try to obtain the DynamicForm by Canvas.getById(), then its DynamicForm fields and from there the PickerIcon like this:
Code:
final DynamicForm dynamicForm = (DynamicForm) Canvas.getById("ViewsForm"); FormItem[] fields = dynamicForm.getFields(); final FormItem formItemField = dynamicForm.getField("ViewsFormSelectItem2"); FormItemIcon editIcon = formItemField.getIcon("EditViewButton2"); editIcon.addFormItemClickHandler(new FormItemClickHandler() { @Override public void onFormItemClick(FormItemIconClickEvent event) { SC.say(formItemField+" button clicked."); } }) SC.say("HandlerCount: "+ editIcon.getHandlerCount(new Type<FormItemClickHandler>()));
In addition, the onFormItemClick is never invoked when clicking on the icon (no popup).
Maybe this is a similar problem as described here: http://forums.smartclient.com/showthread.php?t=26343
except that this time, the widgeds could not be replaced by their global counterparts and the global ones are somehow shadowed by the "anonymous" ones?
By inspecting the FormItemIcon/PickerIcon using Firefox, I see this (which weakens the assumption above):
Code:
<span id="isc_3A" handlenativeevents="false" $9a="EditViewButton2" $89="ViewsFormSelectItem" tabindex="4040" style="margin-left:0px;-moz-user-focus:normal;cursor:pointer" role="button"></span>
Code:
GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void onUncaughtException(Throwable e) { GWT.log("Uncaught exception",e); } });
Code:
com.google.gwt.dev.shell.HostedModeException: Something other than a boolean was returned from JSNI method '@com.smartgwt.client.widgets.form.fields.FormItem::isCreated()': JS value of type undefined, expected boolean at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:100) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeBoolean(ModuleSpace.java:196) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeBoolean(JavaScriptHost.java:35) at com.smartgwt.client.widgets.form.fields.FormItem.isCreated(FormItem.java) at com.smartgwt.client.widgets.form.fields.FormItem.setAttribute(FormItem.java:4123) at com.smartgwt.client.widgets.form.fields.FormItem.setName(FormItem.java:4397) at com.smartgwt.client.widgets.form.fields.FormItem.<init>(FormItem.java:109) at com.smartgwt.client.widgets.form.fields.TextItem.<init>(TextItem.java:113) at com.smartgwt.client.widgets.form.fields.FormItemFactory.getFormItem(FormItemFactory.java:13) at com.smartgwt.client.widgets.form.DynamicForm.convertToFormItemArray(DynamicForm.java:3274) at com.smartgwt.client.widgets.form.DynamicForm.getFields(DynamicForm.java:3260) at com.myCompany.myOnLoadClass$2.execute(MyOnLoadClass.java:77) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364) at java.lang.Thread.run(Thread.java:722)
FF 20.0.1 & Version 26.0.1410.64 m
v8.3p_2013-04-28/PowerEdition Deployment (built 2013-04-28)
Thanks,
fatzopilot
Comment