Creating custom plugin in system namespace gives template error

Hi,
We have to integrate select drop down with API based options. For that we created an custom plugin and configured in system namespace(hippo:namespaces/system/customPlugin). While adding this plugin document type, it gives below error. But we have required fields customPlugin.html template.

[INFO] [talledLocalContainer] 12.05.2023 18:35:34 ERROR http-nio-8081-exec-3 [SwallowExceptionMapper.mapUnexpectedExceptions:35] Unexpected error occurred
[INFO] [talledLocalContainer] org.apache.wicket.markup.MarkupNotFoundException: No Markup found for Fragment selectOptionAPI in providing markup container [customPlugin [Component id = item]]
[INFO] [talledLocalContainer]   at org.apache.wicket.markup.html.panel.FragmentMarkupSourcingStrategy.getMarkup(FragmentMarkupSourcingStrategy.java:148) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.markup.html.panel.Fragment.newDequeueContext(Fragment.java:139) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.MarkupContainer.dequeue(MarkupContainer.java:1989) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.MarkupContainer.onInitialize(MarkupContainer.java:2021) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.Component.fireInitialize(Component.java:878) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.MarkupContainer$3.component(MarkupContainer.java:1077) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.MarkupContainer$3.component(MarkupContainer.java:1073) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144) ~[wicket-util-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162) ~[wicket-util-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162) ~[wicket-util-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162) ~[wicket-util-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162) ~[wicket-util-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123) ~[wicket-util-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:192) ~[wicket-util-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:984) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.MarkupContainer.internalInitialize(MarkupContainer.java:1072) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.MarkupContainer.addedComponent(MarkupContainer.java:1048) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.MarkupContainer.add(MarkupContainer.java:242) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.markup.repeater.RefreshingView.addItems(RefreshingView.java:191) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.markup.repeater.RefreshingView.onPopulate(RefreshingView.java:97) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.markup.repeater.AbstractRepeater.onBeforeRender(AbstractRepeater.java:124) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.markup.repeater.AbstractPageableView.onBeforeRender(AbstractPageableView.java:115) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.Component.internalBeforeRender(Component.java:950) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.Component.beforeRender(Component.java:1018) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1826) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.Component.onBeforeRender(Component.java:3921) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.hippoecm.frontend.service.render.AbstractRenderService.onBeforeRender(AbstractRenderService.java:525) ~[hippo-cms-api-14.7.13.jar:14.7.13]
[INFO] [talledLocalContainer]   at org.hippoecm.frontend.editor.plugins.field.AbstractFieldPlugin.onBeforeRender(AbstractFieldPlugin.java:343) ~[hippo-cms-editor-frontend-14.7.13.jar:14.7.13]
[INFO] [talledLocalContainer]   at org.hippoecm.frontend.editor.plugins.field.PropertyFieldPlugin.onBeforeRender(PropertyFieldPlugin.java:183) ~[hippo-cms-editor-frontend-14.7.13.jar:14.7.13]
[INFO] [talledLocalContainer]   at org.apache.wicket.Component.internalBeforeRender(Component.java:950) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.Component.beforeRender(Component.java:1018) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1826) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.apache.wicket.Component.onBeforeRender(Component.java:3921) ~[wicket-core-7.18.0.jar:7.18.0]
[INFO] [talledLocalContainer]   at org.hippoecm.frontend.service.render.AbstractRenderService.onBeforeRender(AbstractRenderService.java:525) ~[hippo-cms-api-14.7.13.jar:14.7.13]

Thanks,
Gnana moorthi

Wicket is not very forgiving if you are missing a wicket:id in your HTML file…does your HTML file contains selectOptionAPI? (something like wicket:id=“selectOptionAPI” ?

1 Like

Yes, this was added in html file. Is this html file need to register in any place. If any documentation out there?

Hey @gnanamoorthi ,

could you please share the documentation page that you followed and also the full class and HTML files you have implemented?

Thanks

@Lef_Karamoulas

This custom plugin code was copied from existing plugin org.onehippo.forge.selection.frontend.plugin.DynamicDropdownPlugin class and updated template file wicket:id field values. We couldn’t find any documentation.

String mode = config.getString("mode");
        if ("edit".equals(mode)) {
            this.add(new Component[]{this.createSelect(configuredValueList)});
            Label valueLabel = new Label("selectAPILabel");
            valueLabel.setVisibilityAllowed(true);
            this.add(new Component[]{valueLabel});
        } else {
            DropDownChoice<?> dummyChoice = new DropDownChoice("selectAPIDropdown");
            dummyChoice.setVisibilityAllowed(true);
            this.add(new Component[]{dummyChoice});
            Label label = this.createValueLabel(configuredValueList, mode);
            this.add(new Component[]{label});
        }

html file


<html xmlns:wicket="http://wicket.apache.org/">

<wicket:panel>
    <wicket:container wicket:id="fragment" />
</wicket:panel>

<wicket:fragment wicket:id="edit">
    <wicket:fragment wicket:id="selectAPIOptionGroup">
        <optgroup wicket:id="optionAPIGroup" label="">
            <wicket:container wicket:id="optionAPIGroupItems">
                <option wicket:id="optionAPI">option</option>
            </wicket:container>
        </optgroup>
    </wicket:fragment>
    <wicket:fragment wicket:id="selectOptionAPI">
        <option wicket:id="optionAPI"><span wicket:id="optionAPILabel"/> </option>
    </wicket:fragment>
    <select wicket:id="selectAPIDropdown" class="dropdown-plugin">
        <span wicket:id="selectAPIDropdownItem"/>
    </select>
    <span wicket:id="selectAPILabel" class="test">Test</span>
    <select class="test">
        <option>TEST</option>
    </select>
</wicket:fragment>

<wicket:fragment wicket:id="view">
    <select wicket:id="selectAPIDropdown" class="dropdown-plugin">
        <span wicket:id="selectAPIDropdownItem"/>
    </select>
    <span wicket:id="selectAPILabel"></span>
</wicket:fragment>

</html>

@machak
yes it was, you con refer html file in below reply.

One thing to check is whether the .html file ends up in the jar, side by side of the .class file. If not, you’d need to tweak the pom.xml to include non-Java files, typically by:

  <build>
    <resources>
      <resource>
        <filtering>false</filtering>
        <directory>${basedir}/src/main/java</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.html</include>
          <include>**/*.css</include>
        </includes>
      </resource>
    </resources>
  </build>

HTH
Jeroen

1 Like

Thanks @jeroen.hoffman
this changes resolved the issue.