Primefaces override doesn't work after non aja

2019-07-15 10:25发布

I'm faced with an annoying primefaces-bug. I have 2 commandLinks for changing languages:

<p:commandLink action="#{language.setLanguage('de')}"
                            ajax="false">
                            <h:graphicImage value="/resources/images/flags/germany.png"
                                style="vertical-align: middle;width:40px;height:34px" />
                        </p:commandLink>

if I change the locale now, the page is reloaded but it seems like the primefaces overrides are gone. At least the texts are bigger... Is this a familliar issue?

regards

1条回答
老娘就宠你
2楼-- · 2019-07-15 11:14

I would have just commented, rather than posting an answer but I'm lacking the points :).

If you are seeing styles disappearing when changing locale, I suspect is it your resource locator that may be the cause. Per JSF 2.1 specification, Section 2.6.1.3 (JSR-000314) a resource identifier can consist of the following elements

[localePrefix/][libraryName/][libraryVersion/]resourceName[/resourceVersion]

Assuming you have a style sheet app.css, using

<h:outputStyleSheet library="css" name="app.css" />

would locate the resource at <root>/resources/css/app.css. I suspect if you programmatically change the local to something other than your default locale, say Italian (i.e. it), then JSF will look for your resource in <root>/resources/it/css/app.css. Its only a hunch. I just recently started looking at what is requires to do localization and I recalled JSF having a means to organize locale-specific resources.

查看更多
登录 后发表回答