wicketstuff / core

Wicketstuff-core projects are bundled user contributions for use with Apache Wicket (https://wicket.apache.org/). They are released in step with Wicket releases to make them easy to use.
336 stars 299 forks source link

#926 Use Webjars for JQueryUI #927

Closed mcr-paulanand closed 1 month ago

mcr-paulanand commented 1 month ago

Resolves #926

solomax commented 1 month ago

Hello @martin-g,

It seems this PR breaks samples

Webjars are being used from Initializer from now on

so we got

Caused by: java.lang.IllegalStateException: you have to call WicketWebjars.install() before you can use an IWebjarsResourceReference or any other component.
    at de.agilecoders.wicket.webjars.WicketWebjars.settings (WicketWebjars.java:136)
    at de.agilecoders.wicket.webjars.util.WebjarsVersion$Holder.<clinit> (WebjarsVersion.java:29)
    at de.agilecoders.wicket.webjars.util.WebjarsVersion.useRecent (WebjarsVersion.java:45)
    at de.agilecoders.wicket.webjars.request.resource.WebjarsJavaScriptResourceReference.<init> (WebjarsJavaScriptResourceReference.java:29)
    at org.wicketstuff.jquery.ui.resource.JQueryUIResourceReference.<init> (JQueryUIResourceReference.java:54)
    at org.wicketstuff.jquery.ui.resource.JQueryUIResourceReference.<clinit> (JQueryUIResourceReference.java:37)
    at org.wicketstuff.jquery.ui.settings.JQueryUILibrarySettings.<init> (JQueryUILibrarySettings.java:49)
    at org.wicketstuff.jquery.ui.settings.JQueryUILibrarySettings.get (JQueryUILibrarySettings.java:61)
    at org.wicketstuff.jquery.ui.theme.Initializer.init (Initializer.java:37)
    at org.apache.wicket.Application.initInitializers (Application.java:561)
    at org.apache.wicket.Application.initApplication (Application.java:767)
    at org.apache.wicket.protocol.http.WicketFilter.init (WicketFilter.java:441)

due to WicketWebjars.install(this); is being called in the init() i.e. too late :(

What can be done here?

martin-g commented 1 month ago

As error message suggests we need to add 'WicketWebjars.install()' to the respective WebApplication#init()

martin-g commented 1 month ago

Oh, now I see the text after the stacktrace. I think it should be OK to call it in an initializer too.

solomax commented 1 month ago

Works as expected!

Thanks a million @martin-g :)

reckart commented 1 month ago

due to WicketWebjars.install(this); is being called in the init() i.e. too late :(

@solomax so how did you solve this?

solomax commented 1 month ago

@solomax so how did you solve this?

https://github.com/wicketstuff/core/blob/master/wicketstuff-jquery-ui-parent/wicketstuff-jquery-ui-themes/wicketstuff-jquery-ui-theme-base/src/main/java/org/wicketstuff/jquery/ui/theme/Initializer.java#L36

:))

reckart commented 1 month ago

I think this change needs to be made in the initializer of all of the themes separately.

solomax commented 1 month ago

I think this change needs to be made in the initializer of all of the themes separately.

I also thought so

But I believe right now it's not necessary due to the fact the only theme uses webjar so far :)

mcr-paulanand commented 1 month ago

I think this change needs to be made in the initializer of all of the themes separately.

I also thought so

But I believe right now it's not necessary due to the fact the only theme uses webjar so far :)

I have created a PR #934 to resolve this