How to change location of ValidationMessages.properties in Bean Validation - java-ee-6

By default, ValidationMessages.properties can be located in root of my classpath. Can I change the location of this file like com.myapp.Anything.properties?

From the JSR-303 specification:
4.3.1.1. Default message interpolation algorithm The default message interpolator uses the following steps:
Message parameters are extracted from the message string and used as keys to search the ResourceBundle named ValidationMessages (often
materialized as the property file /ValidationMessages.properties and
its locale variations) using the defined locale (see below). If a
property is found, the message parameter is re- placed with the
property value in the message string. Step 1 is applied recursively
until no replacement is per- formed (i.e. a message parameter value
can itself contain a message parameter).
It seems that this is the default and the suggestion. To back this up the JSR-303 TCK uses TestNG to move them to the "WEB-INF/classes/" directory which is the same as "./" on the resources classpath.
(You can experiment with it but that's about all I can figure out.)
Sorry.

Related

AssetBundleBuild addressableNames vs assetNames

Can someone help me understand the difference between the AssetBundleBuild.addressableNames and AssetBundleBuild.assetNames?
Also can I use BuildPipeline.BuildAssetBundles with AssetBundleBuild[] parameter to build specific asset bundles and not all of them (the overload without this parameter) ?
AssetBundleBuild.assetNames identifies the exact location and name for bundling an asset. (assume buildMap is of type AssetBundleBuild)
buildMap[0].assetNames[0] = "Assets/Textures/stinky_pupper_smol.jpg";
AssetBundleBuild.addressableNames is an optional nickname for loading the asset its array index corresponds to.
buildMap[0].addressableNames[0] = "DogTexture";
That's all done during build time so during runtime you can load that texture like this (assume bundle is of type AssetBundle):
bundle.LoadAsset("DogTexture");
instead of:
bundle.LoadAsset("Assets/Textures/stinky_pupper_smol.jpg");
For your second question, yes. The overload of BuildPipeline.BuildAssetBundles with an AssetBundleBuild[] as an argument will ignore your bundles identified in the editor:
This variant of the function lets you specify the names and contents
of the bundles using a "build map" rather than with the details set in
the editor. The map is simply an array of AssetBundleBuild objects,
each of which contains a bundle name and a list of the names of asset
files to be added to the named bundle.

AEM: How to find location of Exception on Sightly/HTL page?

I'm working on a fairly large HTL page, which is throwing a:
java.lang.IllegalArgumentException: Invalid property name
How can I find the location in the HTL that's causing this?
UPDATE
The full trace is too big for SO. I saved it here: http://pastebin.com/xajiY5MD
Here's the first few lines:
Invalid property name
Cannot serve request to /content/XXXX/en-us/cart.html in /apps/XXXXcommerce/components/content/cart/cart.html
Exception:
java.lang.IllegalArgumentException: Invalid property name
at org.apache.sling.scripting.sightly.impl.utils.RenderUtils.getProperty(RenderUtils.java:151)
at org.apache.sling.scripting.sightly.impl.utils.RenderUtils.resolveProperty(RenderUtils.java:143)
at org.apache.sling.scripting.sightly.apps.XXXXcommerce.components.content.cart.SightlyJava_cart.render(SightlyJava_cart.java:512)
at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderUnit.render(RenderUnit.java:54)
This comes when you are using a property which is:
1. not defined in dialog
2. You are using it in a wrong manner(Check for double quotes vs single quotes)
3. If you are using java, that property is not present in the java class and you are trying to access it.
Pls check and respond if thats no the case and the resolution too to help others.
java.lang.IllegalArgumentException: Invalid property name without a property name apparently occurs when indexing an array using an empty value (in my case the object containing the index had gone out of scope)

Apache Wicket event on Page "page was mouted on ..."

I have mount Page in this form (with one predefined parameter):
mountPage("/lista/${variant}", StronaEntityV2.class);
when parameter "variant" is given all is OK. But when parameter is absent (is OK too from application point of view) URL is build in form
wicket/bookmarkable/all....package...StronaEntityV2?8
It is ok too, but I will know that situation. In simple situation (with one predefined parameter) checking parameter is good, but in more complicated isn't so simple (and must maintain code in distinct places).
My ideal imaged solution is event
page.OnPageIsMountedOn(URL to_me)
I will accept wide range of solutions.
FORMAL: please integrate synonyms on tags wicket-1.6 & wicket-6, and create new wicket-7
Your page is configured to listen to /lista/${variant}.
When you do: setResponsePage(StronaEntityV2.class, paramsWithVariant) then Wicket will use the mount point and produce: /lista/variantValue.
But if you do: setResponsePage(StronaEntityV2.class), i.e. no PageParameters provided, then Wicket will ignore /lista/${variant} (because it doesn't match) and will produce a "default" page url, i.e. /wicket/bookmarkable/com.example.StronaEntityV2.
So the application controls which url should be used.
You can use optional parameter placeholder: /lista/#{variant}. Note that I use # instead of $ now. This way Wicket will produce /lista/ when there is no variant parameter provided. In the page constructor you will know that the url is always "/lista" but the parameter may be null, so better use: pageParameters.get("variant").toXyz(defaultValue) or .toOptionalXyz().

How to map urls?

I would like to map pages such domain/content/myProject/home.html to domain/home.html. /content/myProject/ is not needed. I have the following code:
String newpath = getResourceResolver().map(page.getPath());
this does not change anything. newpath is stay page.getPath()
how to solve this issue?
Answering as this question as it remains unanswered. Here is an example of how the etc mappings should look like:
Trick is you add 2 entries to sling:internalRedirect as / and /content/example/
AEM first tries to resolve resources with first entry '/'. So non page URLs like /etc/designs, /content/dam etc will be addressed by the first entry. If it is unable to resolve using the first one, it uses the second entry to resolve the page.
This is also the adobe recommended way for URL shortening compared to other techniques like apache redirect.
You need to create map in etc.Then Resource Resolver will take care of trimming the path .
CREATING MAPPING DEFINITIONS IN AEM
In a standard installation of AEM you can find the folder:
/etc/map/http
This is the structure used when defining mappings for the HTTP protocol. Other folders (sling:Folder) can be created under /etc/map for any other protocols that you want to map.
Configuring an Internal Redirect to /content
To create the mapping that prefixes any request to http://localhost:4503/ with /content:
Using CRXDE navigate to /etc/map/http.
Create a new node:
Type sling:Mapping
This node type is intended for such mappings, though its use is not mandatory.
Name localhost_any
Click Save All.
Add the following properties to this node:
Name sling:match
Type String
Value localhost.4503/
Name sling:internalRedirect
Type String
Value /content/
Click Save All.
This will handle a request such as:
localhost:4503/geometrixx/en/products.html
as if:
localhost:4503/content/geometrixx/en/products.html
had been requested.
You can refer here for further documentation http://docs.adobe.com/docs/en/cq/5-6-1/deploying/resource_mapping.html

Play framework localisation is not working in production

If I run my play framework application with "play run" the localisation is fine. But if I do a "play dist" then use the start command, then the original English messages appear.
I have found, that if I change the classpath order in the start script putting the jar containing my messages file to the first place, then the localisation is fine.
Is there any better way to do this?
It is the same, if I copy the conf/messages to conf/messages.hu and set application.langs="hu" in the application.conf.
And stays the same, if I change my browser settings, so this is in the request header: "Accept-Language:hu,en-US;q=0.8,en;q=0.6". Still English messages (only, if they are the built in keys. My custom keys are translated correctly).
We have figured it out.
There is a custom field constructor used. My assumption was, that it is using the implicit lang parameter, but this is not the case. The lang must be given to the elements.errors() as parameter, and the current lang setting is stored in the elements.lang attribute. This is stated in the documentation, but we missed it. So the implicit lang parameter should not be used in the field template, because it contains wrong value.
The solution was this: #elements.errors(elements.lang)
#elements.input
<span class="errors">#elements.errors(elements.lang).mkString(", ")</span>