[opencms-dev] Adding own custom widget

Daniel Seidel d.seidel at alkacon.com
Wed Feb 24 09:04:12 CET 2021


Hi Anne,

it's in the JavaScript. You may install the example widget from the 
documentation and play a bit with it. The JavaScript is really 
well-documented. I also just updated the source on GitHub, so you might 
exchange the 
https://github.com/alkacon/opencms-documentation/blob/branch_11_0_x/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/resources/system/modules/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/resources/js/examplewidget.js 
<https://github.com/alkacon/opencms-documentation/blob/branch_11_0_x/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/resources/system/modules/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/resources/js/examplewidget.js> 
in your installation, since I fixed some style classes that were not 
correct.

Best, Daniel.

PS: Here's an Example on how you configure the widget in an XSD: 
https://github.com/alkacon/opencms-documentation/blob/branch_10_5_x/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/resources/system/modules/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/schemas/documentation-native-widget-example.xsd 
<https://github.com/alkacon/opencms-documentation/blob/branch_10_5_x/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/resources/system/modules/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/schemas/documentation-native-widget-example.xsd>. 
Of course, Field Settings syntax alternatively works as well.

Am 23.02.21 um 13:58 schrieb Gebert, Anne:
>
> Hi Daniel,
>
> do I have to implement the method setValue in Java or in the js file? 
> How can I access values from the editor in js which are already filled in?
>
> Regards,
>
> Anne
>
> *Von:*opencms-dev <opencms-dev-bounces at opencms.org> *Im Auftrag von 
> *Daniel Seidel
> *Gesendet:* Dienstag, 23. Februar 2021 10:45
> *An:* opencms-dev at opencms.org
> *Betreff:* Re: [opencms-dev] Adding own custom widget
>
> Hi Anne,
>
> have you checked out the example from the OpenCms documentation: 
> https://documentation.opencms.org/opencms-documentation/extending-opencms/extending-the-content-editor/writing-native-editor-widgets/ 
> <https://documentation.opencms.org/opencms-documentation/extending-opencms/extending-the-content-editor/writing-native-editor-widgets/>?
>
> It basically refers to the demo implementation from 
> https://github.com/alkacon/opencms-documentation/tree/branch_11_0_x/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget 
> <https://github.com/alkacon/opencms-documentation/tree/branch_11_0_x/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget>.
>
> In particular in example's JS there are hints how to get the value: 
> https://github.com/alkacon/opencms-documentation/blob/branch_11_0_x/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/resources/system/modules/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/resources/js/examplewidget.js 
> <https://github.com/alkacon/opencms-documentation/blob/branch_11_0_x/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/resources/system/modules/com.alkacon.opencms.documentation.examples.contenteditor.nativewidget/resources/js/examplewidget.js>. 
> It tells to implement a setValue method that should be called by the 
> editor for filling in the value.
>
> Best, Daniel.
>
> Am 22.02.21 um 13:57 schrieb Gebert, Anne:
>
>     Hi list,
>
>     I try to develop a custom widget (opencms 11.0.2) with access to
>     the values already filled in but I am not able to read the values.
>     Do I have to do that in der js? How can I access values from the
>     content element?
>
>     Thanks in advance!
>
>     Regards,
>
>     Anne
>
>
>
>     _______________________________________________
>
>     This mail is sent to you from the opencms-dev mailing list
>
>     To change your list options, or to unsubscribe from the list, please visit
>
>     https://lists.opencms.org/mailman/listinfo/opencms-dev  <https://lists.opencms.org/mailman/listinfo/opencms-dev>
>
> -- 
> Kind Regards
> Daniel.
> -------------------
> Daniel Seidel
> Alkacon Software GmbH & Co. KG - The OpenCms Experts
> https://www.alkacon.com  <https://www.alkacon.com>  -http://www.opencms.org  <http://www.opencms.org>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> https://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
>
-- 
Kind Regards

Daniel.

-------------------

Daniel Seidel
Alkacon Software GmbH & Co. KG - The OpenCms Experts
https://www.alkacon.com - http://www.opencms.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.opencms.org/pipermail/opencms-dev/attachments/20210224/9cb560d5/attachment.htm>


More information about the opencms-dev mailing list