[opencms-dev] Issue on Dependant field on OpenCms 9.5.2

Sandrine Prousteau s.prousteau at eurelis.com
Wed May 25 17:56:40 CEST 2016


Hi,

I’m trying to add dependant field behavior on existing fields.

It works well when I try it on new contents, but generate an error on older contents :

25 mai 2016 17:51:50,871 ERROR [ org.opencms.gwt.CmsLogService:  66] Client LOG (Host 192.10.200.111, Address 192.10.200.111, Ticket 1464191510687): (TypeError)
 __gwt$exception: <skipped>: Cannot read property 'q' of undefined
Unknown.cTc(http://arkcore952.spr:8080/opencms/resources/ade/containerpage/FE55ADF64471C23FD6B850CA47E2CED6.cache.html@25)
Unknown.eTc(http://arkcore952.spr:8080/opencms/resources/ade/containerpage/FE55ADF64471C23FD6B850CA47E2CED6.cache.html@131)
Unknown.qPe(http://arkcore952.spr:8080/opencms/resources/ade/containerpage/FE55ADF64471C23FD6B850CA47E2CED6.cache.html@60)
Unknown._Pe(http://arkcore952.spr:8080/opencms/resources/ade/containerpage/FE55ADF64471C23FD6B850CA47E2CED6.cache.html@117)
Unknown._Pe(http://arkcore952.spr:8080/opencms/resources/ade/containerpage/FE55ADF64471C23FD6B850CA47E2CED6.cache.html@1244)
Unknown._Pe(http://arkcore952.spr:8080/opencms/resources/ade/containerpage/FE55ADF64471C23FD6B850CA47E2CED6.cache.html@1244)
Unknown._Pe(http://arkcore952.spr:8080/opencms/resources/ade/containerpage/FE55ADF64471C23FD6B850CA47E2CED6.cache.html@1244)
Unknown._Pe(http://arkcore952.spr:8080/opencms/resources/ade/containerpage/FE55ADF64471C23FD6B850CA47E2CED6.cache.html@1244)
Unknown._Pe(http://arkcore952.spr:8080/opencms/resources/ade/containerpage/FE55ADF64471C23FD6B850CA47E2CED6.cache.html@1244)
Unknown._Pe(http://arkcore952.spr:8080/opencms/resources/ade/containerpage/FE55ADF64471C23FD6B850CA47E2CED6.cache.html@1244)


The action is this one :

public CmsXmlContent handleChange(
      CmsObject cms,
      CmsXmlContent content,
      Locale locale,
      Collection<String> changedPaths) {

    if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_targetField)) {
      for (String path : changedPaths) {
        I_CmsXmlContentValue value = content.getValue(path, locale);
        LOG.debug("Dependant field checker behavior found on " + path + "(" + locale + ")");
        if (value != null) {
          String val = value.getStringValue(cms);
          LOG.debug("Field found on " + path + "(" + locale + "), value is " + val);

          String target = resolveRelativePath(path, m_targetField);
          LOG.debug("Target field of " + path + "(" + locale + ") is " + target);
          (content.hasValue(target, locale) ?
           content.getValue(target, locale) :
           content.addValue(cms, target, locale, 0)).setStringValue(cms, Boolean.toString(CmsStringUtil.isNotEmptyOrWhitespaceOnly(val)));
        }else{
          LOG.debug("No field found on " + path + "(" + locale + ")");
        }
      }
    }else{
      LOG.error("Missing target xpath in dependant field checker behavior");
    }
    return content;

  }

It’s applied with

<editorchangehandlers>
        <editorchangehandler class="mymodule.CmsEditorChangeHandlerChecker" scope="Paragraph*/Column*/BackgroundColor" configuration="../KnowMoreBlock" />
</editorchangehandlers>


Does someone have a clue?

Thanks,
Sandrine

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20160525/415873d1/attachment.htm>


More information about the opencms-dev mailing list