[opencms-dev] The custum widgets in the OAMP Calendar_1.0.0.

Hein van der Kallen hvanderkallen at xs4all.nl
Sun Mar 14 14:37:17 CET 2021


Hi all

I found a solution.

I only need a solution for creating and editing new serial date entries in
the new workplace. 

The Calendar views get information about the content of the original widget
in the name-value pairs in property calendar.startdate. That property
contains something like

endtype=2|startdate=1258573080000|interval=1|serialenddate=1258498800000|occ
urences=2|weekdays=5|enddate=1258573080000|type=2

 

Some names are required, some are optional depending on your choice for
type: Daily/Weekly/Monthly/Yearly. 

The pairs are read as a Map, so the ordering is irrelevant, you may supply
more pairs then required, as long as you supply pairs for all names needed
depending on your choice . 

The java source of the module is available at 

https://github.com/alkacon/alkacon-oamp/tree/branch_7_x/com.alkacon.opencms.
calendar/src/com/alkacon/opencms/calendar

The required values can be found in CmsCalendarSerialDateFactory.java and
are defined and I_CmsCalendarSerialDateOptions.java

 

I need to support only the Daily and Weekly variants so I need to able to
supply name-value pairs for 

startdate, enddate, type, interval, everyworkingday, weekdays, endtype,
occurrences and serialenddate

 

So I made a copy of the serialentry.xsd as serialentry2.xsd and a
corresponding resourcetype alkacon-cal-serial2 and explorertype. And added
corresponding values in workplace.properties.  

 

Then registered that new resourcetype in calendarviewresconf.xsd (compare
<http://opencms.996256.n3.nabble.com/OAMP-Calendar-and-ttevent-td19098.html>
http://opencms.996256.n3.nabble.com/OAMP-Calendar-and-ttevent-td19098.html)

and in my alkacon-calendar-view instance.

That gives a working alkacon-cal-serial2 resourcetype. 

In serialentry2.xsd I already had removed the lines for the change element (
see previous mail) 

Now I remove the old handler

<handler class="com.alkacon.opencms.calendar.CmsSerialDateXmlContentHandler"
/>

And the old serialDate widget

               <layout element="Serialdate" widget="SerialDateWidget"
configuration="" />

 

Added input fields for each of the required names: 

                                             <xsd:element name="Startdate"
type="OpenCmsDateTime" />

                                            <xsd:element name="Enddate"
type="OpenCmsDateTime" />

                                            <xsd:element name="Type"
type="OpenCmsString" />

                                            <xsd:element name="Interval"
type="OpenCmsString" />

                                            <xsd:element
name="Everyworkingday" type="OpenCmsString" />

                                            <xsd:element name="Weekdays"
type="OpenCmsString" />

                                            <xsd:element name="Endtype"
type="OpenCmsString" />

                                            <xsd:element name="Occurrences"
type="OpenCmsString" />

                                            <xsd:element
name="Serialenddate" type="OpenCmsDateTime" />

 

And mapped these using macro's on the SerialDate

<default element="Serialdate"

value="startdate=%(value:Startdate[1])|enddate=%(value:Enddate[1])|type=%(va
lue:Type[1])|interval=%(value:Interval[1])|everyworkingday=%(value:Everywork
ingday[1])|weekdays=%(value:Weekdays[1])|endtype=%(value:Endtype[1])|occuren
ces=%(value:Occurrences)|serialenddate=%(value:Serialenddate[1])" 

resolveMacros="false" />

That gives a functional working resourcetype alkacon-cal-serial2 : 

When I enter the correct values in the new fields they get copied to
property calendar.startdate and are correctly interpreted in my
calendar(side) views. 

The Serialdate field itself is not changed. 

To make it userfriendly I have to add widgets, defaults, displaynames ,
helptexts etc. 

And I have to make sure that the user cannot see or change the SerialDate
element. 

That is standard xml-content design, 

But as a start ( I peeked in  the original
/system/workplace/resources/components/widgets/serialdate_form.html)

I added

                                                           <layout
element="Type" widget="RadioSelectWidget"         

                              configuration="1:
%(key.GUI_SERIALDATE_TYPE_DAILY_0)|2*: %(key.GUI_SERIALDATE_TYPE_WEEKLY_0)"
/>

                              

                                                           <layout
element="Everyworkingday" widget="RadioSelectWidget" 

                              configuration="false*: All days|true: Only
working days" />

                              

                                                           <layout
element="Weekdays" widget="MultiSelectWidget" 

        configuration="2 option='%(key.GUI_SERIALDATE_DAY_MONDAY_0)'|3
option='%(key.GUI_SERIALDATE_DAY_TUESDAY_0)'

|4 option='%(key.GUI_SERIALDATE_DAY_WEDNESDAY_0)'|5
option='%(key.GUI_SERIALDATE_DAY_THURSDAY_0)'

|6 option='%(key.GUI_SERIALDATE_DAY_FRIDAY_0)'|7*
option='%(key.GUI_SERIALDATE_DAY_SATURDAY_0)'|1
option='%(key.GUI_SERIALDATE_DAY_SUNDAY_0)'" />

                              

                                                           <layout
element="Endtype" widget="RadioSelectWidget" 

        configuration=" 1: %(key.GUI_SERIALDATE_DURATION_ENDTYPE_NEVER_0)|
2*: Ends after ... Occurences|3: Ends at Serialenddate" />

                                                           <layout
element="Serialdate" widget="DisplayWidget"  />

 

The rest will be polishing. 

The alkacon-cal-serial2 resourcetype uses no custom widget or custom handler
and is useable in all editors in old and new Workplace.

 

Hein van der Kallen

 

 

Van: opencms-dev <opencms-dev-bounces at opencms.org> Namens Hein van der
Kallen
Verzonden: woensdag 3 maart 2021 14:46
Aan: opencms-dev at opencms.org
Onderwerp: [opencms-dev] The custum widgets in the OAMP Calendar_1.0.0.

 

The custom widgets in the OAMP Calendar_1.0.0.

The Alkacon_OAMP_Calendar_1.0.0 was part of Alkacon OpenCms Add-On Module
Package (OAMP).

It dates from 2008. We use it since 2009.

Installation required two "custom" widgets defined in opencms-vfs.xml with 

<widget class="com.alkacon.opencms.calendar.CmsSerialDateWidget"
alias="SerialDateWidget"/>

<widget class="com.alkacon.opencms.calendar.CmsSerialDateSelectWidget"
alias="SerialDateSelectWidget"/>

 

These custom widgets are used in the schema of the "alkacon-cal-serial"
resourcetype in 

serialentry.xsd.

Editing (or Creating) a resource of type alkacon-cal-serial increasingly
gives problems. 

It is an old module, so let me start with using the old workplace in opencms
10.5.4. 

In the old workplace we can set the user preference for editing xml content
on "Default page editor". 

Then we can correctly edit an alkacon-cal-serial resource and especially the
serial date, using the original widget. 

We then use the /system/workplace/editors/xmlcontent/editor.jsp

Trying to add a "change" group element gives an error.

We don't need the optional "Change" so I delete in serialentry.xsd the lines

                              <xsd:element name="Change"
type="OpenCmsAlkaconCalendarSerialDateChange" minOccurs="0" maxOccurs="52"
/>

                              <default element="Change/Showtime"
value="true" />

                              <default element="Change/Time"
value="%(key.calendar.defaults.time)" />

Opencms 11 has its own SerialDateWidget. 

To avoid confusion I use the fully qualified name for the widget in
serialentry.xsd

                              <layout element="Serialdate"
widget="com.alkacon.opencms.calendar.CmsSerialDateWidget" configuration=""
/>

 

But still I cannot edit alkacon-cal-serial resource correctly in the new
workplace. (opencms 10 or 11).

Is there a (best) way to get alkacon-cal-serial correctly editable in the
new workplace ?

( I can hack it using edit controlcode, but consider that not a usable
solution). 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.opencms.org/pipermail/opencms-dev/attachments/20210314/3601ebc6/attachment.htm>


More information about the opencms-dev mailing list