Customize the Login Form, new field not showing

I’m following the Customize the Login Page - Bloomreach Experience - Headless Digital Experience Platform, Customize the Login Form to add a field to the login form with an archetype 14.5.0.

It will not add the field to the page, I do get de error message “‘companyName’ is required”.
Adding the html via the inspect works, I can log in.

No error messages in the log.

Tried to update/change the CustomLoginPlugin by looking at the reset password forge code to:

public class CustomLoginPlugin extends DefaultLoginPlugin {

private String companyName;

public CustomLoginPlugin(final IPluginContext context, final IPluginConfig config) {
    super(context, config);
}

protected LoginPanel createLoginPanel(final String id, final LoginConfig config, final LoginHandler handler) {
    return new CustomLoginForm(id, config, handler);
}

class CustomLoginForm extends LoginPanel {

    protected final RequiredTextField<String> companyNameTextField;
    protected final IModel<String> companyNamePlaceholder;

    public CustomLoginForm (final String id, final LoginConfig config, final LoginHandler handler) {
        super(id, config, handler);
        final IModel<String> companyNameModel = PropertyModel.of(CustomLoginPlugin.this, "companyName");
        this.companyNameTextField = new RequiredTextField<>("companyName", companyNameModel);
        form.add(this.companyNameTextField);
        this.companyNamePlaceholder = new LoginResourceModel("companyName-label", new Object[0]);
        form.addAjaxAttributeModifier(this.companyNameTextField, "placeholder", this.companyNamePlaceholder);
    }

    @Override
    protected void loginSuccess() {
        Session.get().setAttribute("companyName", companyName);
        super.loginSuccess();
    }
}

}

Debugging, google Wicket stuff and more, checked the resource html part but I cannot find out why the resource html will not add as described in the above link.

Please help!

Kind regards, Kitty.

It’s probably because your custom template does not include the <input wicket:id="companyName"/> for some reason, or because your custom html template is not found in the classpath of the /cms web application, i.e. $CATALINA_BASE/webapps/cms/WEB-INF/classes/.../CustomLoginPlugin$CustomLoginForm.html.

If you cannot find the clues yet, consider enabling the debug mode (development) of Wicket too while debugging in cms/WEB-INF/web.xml:

  <!--Default application-->
  <filter>
    <filter-name>CMS</filter-name>
    <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
    <!-- SNIP -->
    <init-param>
      <param-name>wicket.configuration</param-name>
      <param-value>development</param-value>
    </init-param>
    <!-- SNIP -->
  </filter>

Thanks for your reaction!
Picked up a 14.6.0 archetype, added the code according to Customize login page, added the Wicket debug, the result:
Root cause:

org.apache.wicket.WicketRuntimeException: The component(s) below failed to render. Possible reasons could be that:
1) you have added a component in code but forgot to reference it in the markup (thus the component will never be rendered),
2) if your components were added in a parent container then make sure the markup for the child container includes them in wicket:extend.

  1. [RequiredTextField [Component id = companyName, page = org.hippoecm.frontend.PluginPage, path = root:login-panel:login-form:companyName, type = org.apache.wicket.markup.html.form.RequiredTextField, isVisible = true, isVersioned = false]]

    at org.apache.wicket.Page.checkRendering(Page.java:666)
    at org.apache.wicket.Page.onAfterRender(Page.java:821)
    at org.apache.wicket.markup.html.WebPage.onAfterRender(WebPage.java:224)
    at org.hippoecm.frontend.PluginPage.onAfterRender(PluginPage.java:307)
    at org.apache.wicket.Component.afterRender(Component.java:919)
    at org.apache.wicket.Component.render(Component.java:2343)
    at org.apache.wicket.Page.renderPage(Page.java:1018)
    at org.hippoecm.frontend.PluginPage.renderPage(PluginPage.java:429)
    at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:124)
    at org.hippoecm.frontend.Main$7$1.renderPage(Main.java:546)
    at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:236)
    at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)
    at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:895)
    at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
    at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265)
    at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222)
    at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
    at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261)
    at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:203)
    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:284)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.hippoecm.frontend.plugins.login.ConcurrentLoginFilter.doFilter(ConcurrentLoginFilter.java:42)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.hippoecm.hst.core.container.FilterChainInvokingValve.invoke(FilterChainInvokingValve.java:72)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288)
    at org.hippoecm.hst.core.container.JCRSessionStatefulConcurrencyValve.invoke(JCRSessionStatefulConcurrencyValve.java:56)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288)
    at org.hippoecm.hst.core.container.SubjectBasedSessionValve.invoke(SubjectBasedSessionValve.java:58)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288)
    at org.hippoecm.hst.core.container.SecurityValve.invoke(SecurityValve.java:177)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288)
    at org.hippoecm.hst.core.container.LocalizationValve.invoke(LocalizationValve.java:101)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288)
    at org.hippoecm.hst.core.container.CmsSecurityValve.invoke(CmsSecurityValve.java:75)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288)
    at org.hippoecm.hst.core.container.InitializationValve.invoke(InitializationValve.java:40)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288)
    at org.hippoecm.hst.core.container.HstSitePipeline.invokeValves(HstSitePipeline.java:173)
    at org.hippoecm.hst.core.container.HstSitePipeline.invoke(HstSitePipeline.java:155)
    at org.hippoecm.hst.core.container.HstRequestProcessorImpl.processRequest(HstRequestProcessorImpl.java:82)
    at org.hippoecm.hst.container.HstDelegateeFilterBean.doFilter(HstDelegateeFilterBean.java:624)
    at org.hippoecm.hst.container.DelegatingFilter.doFilter(DelegatingFilter.java:68)
    at org.hippoecm.hst.container.HstFilter.doFilter(HstFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:126)
    at org.springframework.boot.web.servlet.support.ErrorPageFilter.access$000(ErrorPageFilter.java:64)
    at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:101)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

Checked if the html is there, yes:

The html is not added to the login form. Moving it to directly under the Java did not help.
Debugging the code goes deep into BR objects: I see the LoginForm, the companyName has been added to the children in the form in the added code, further debug stepping goes to constructor of LoginPlugin class.

At what point should the html be picked up?

The .html file should be located in the same directory where the CustomLoginPlugin class is located.
From the screenshot, your .html file is not located in the same directory, /WEB-INF/classes/org/example/login/.
To do that properly, you should put the files in this location in your project:

  • cms/src/main/java/org/example/login/CustomLoginPlugin.java
  • cms/src/main/resources/org/example/login/CustomLoginPlugin$CustomLoginForm.html

Regards,

Woonsan

Hi Woonsan,

Thanks again for helping. Found the problem!
The files are in the correct location, followed the instructions to the letter, big difference was that I added a file (Intellij) with and I should have added a HTML file (3 types possible, chose HTML5).

Figured it out because maven was last step to be looking at, why could maven not see html file?

Much Appreciated,
Kitty.