WebHare community

Editing widgets (editfragment, editscreen and editcomponent deprecated)

better-ways
#1

The use of editfragment, editscreen and editcomponent in <widgettype> and <embeddedobjecttype> is deprecated and support for it will be removed in the future. To create an editor for widgets, use editextension or editlibrary and editfunctionname.

Migration

Here are some examples for migrating editfragment and editscreen to editextension.

From editfragment

Convert the fragment into a tabsextension.

For example, if your widget uses:

<widgettype namespace="http://example.org/xmlns/mywidget" editfragment="#mywidget">
  <members>
    <member name="textvalue" type="string" />
  </members>
</widgettype>

<fragment name="mywidget" implementation="none" xmlns="http://www.webhare.net/xmlns/tollium/screens">
  <contents>
    <textedit composition="fsinstance" cellname="textvalue" />
  </contents>
</fragment>

Change the widget type’s editfragment attribute to editextension and change the <fragment> to a <tabsextension>. Make sure to change the implementation from none to p:widgetextension and to use the contentdata composition instead of fsinstance:

<widgettype namespace="http://example.org/xmlns/mywidget" editextension="#mywidget">
  <members>
    <member name="textvalue" type="string" />
  </members>
</widgettype>

<tabsextension name="mywidget" implementation="p:widgetextension" xmlns="http://www.webhare.net/xmlns/tollium/screens">
  <newtab>
    <textedit composition="contentdata" cellname="textvalue" />
  </newtab>
</tabsextension>

From editscreen

Convert the screen into a tabsextension.

For example, if you widget uses:

<widgettype namespace="http://example.org/xmlns/mywidget" editscreen="#mywidget">
  <members>
    <member name="textvalue" type="string" />
  </members>
</widgettype>

<screen name="mywidget" implementation="p:widgetedit" xmlns="http://www.webhare.net/xmlns/tollium/screens">
  <compositions>
    <record name="contentdata" />
  </compositions>
  <body>
    <textedit composition="contentdata" cellname="textvalue" />
  </body>
  <footer>
    <defaultformbuttons buttons="ok cancel" />
  </footer>
</screen>

Change the widget type’s editscreen attribute to editextension and change the <screen> to a <tabsextension>. The contentdata composition is already available within the tabsextention and you no longer need the footer. Make sure you change the implementation from p:widgetedit to p:widgetextension.

<widgettype namespace="http://example.org/xmlns/mywidget" editextension="#mywidget">
  <members>
    <member name="textvalue" type="string" />
  </members>
</widgettype>

<tabsextension name="mywidget" implementation="p:widgetextension" xmlns="http://www.webhare.net/xmlns/tollium/screens">
  <newtab>
    <textedit composition="contentdata" cellname="textvalue" />
  </newtab>
</tabsextension>

Implementation other than none

If you used an explicit implementation instead of none, you’ll have to extend from WidgetEditExtensionBase instead of TolliumFragmentBase. If you were using PreInitComponent or PostInitComponent, you can use InitExtension(OBJECT linescontainer) and PostInitExtension respectively instead. You can still use ValidateValue(OBJECT feedback) to validate your extension’s value.

Optimizations

If your fragment/screen encapsulates a tabs component, you can add the tabs’ tab's as newtab's. For example, if your screen uses:

<screen name="mywidget" implementation="p:widgetedit" xmlns="http://www.webhare.net/xmlns/tollium/screens">
  <compositions>
    <record name="contentdata" />
  </compositions>
  <body spacers="none">
    <tabs>
      <tab title="First">
        <textedit composition="contentdata" cellname="textvalue" />
      </tab>
      <tab title="Second">
        <text title="" value="This is the second tab" />
      </tab>
    </tabs>
  </body>
  <footer>
    <defaultformbuttons buttons="ok cancel" />
  </footer>
</screen>

You can add the tabs directly to the extension:

<tabsextension name="mywidget" implementation="p:widgetextension" xmlns="http://www.webhare.net/xmlns/tollium/screens">
  <newtab title="First">
    <textedit composition="contentdata" cellname="textvalue" />
  </newtab>
  <newtab title="Second">
    <text title="" value="This is the second tab" />
  </newtab>
</tabsextension>
0 Likes

#2

I guess editfragment in the example code is a typo and should’ve been editscreen?

0 Likes

#3

yup

0 Likes