Good Code Practice - Why does eClipse force us to use "only lower-case letters, numbers and !" for Token name? - gwt

Ok, I am using GWTP on eclipse. When creating a Presenter using eclipse & when I enter a token name say "!manageOrder" then eclipse show an error that "Token name must contain only lower-case letters, numbers and !". See the following picture.
However, in the NameTokens class, there is a line:
public static final String manageorder = "!mnageorder";
We can change to lowercase or upper the system is still ok.
So why does eClipse force us to use "only lower-case letters, numbers and !" for Token name?
if i use "!manageOrder" then it must easier for customer to figure out the what the page is right?

I believe this is just best practice being enforced by the version of the GWTP plugin you are using. It looks like you are using the old version of the plugin (for before GWTP 1.0)...
The new plugin allows capitals in the names:
Anyhow I would say use capitals if you want to, as long as it works.
More importantly, get using the current versions of GWTP and the associated plugin: https://github.com/ArcBees/gwtp-eclipse-plugin

Related

Annotated User Expression [dialogFlow]

Just a quick question. I'm currently doing a project using dialogflow and in the past I've used that. Usually under "Training Phrases", there are 2 different annotations. One with "#" and the other with a huge " " " ". Now there isn't a choice for you to choose "#". Does anyone knows how to call out the entity directly?
For eg. # #sys.any:orderFood
As you can see at the bottom of https://dialogflow.com/docs/intents/training-phrases page, Template mode has been deprecated now (the one starting with # sign).
You have to use example mode only from now on.
If you want to use #sys.any:orderFood, simply write a keyword for that and annotate it with the correct entity. It will be same as using #sys.any:orderFood.
Hope it helps.

"SAPUI5 component ID is potentially invalid" on submitting SAPUI5 Application to ABAP System

When I am trying to upload app to ABAP-Repository using SE38 and /UI5/UI5_REPOSITORY_LOAD I get following error message:
SAPUI5 component ID SAPUI5.BRUTTOUMSATZ2 in SAPUI5 repository ZBRUTTOUMSATZ is potentially invalid.
Submitting the Project via eclipse brings up the same error message.
Does anyone know how to fix this issue or what might cause this ? I didn't find any documentation on this error message.
The application runs fine when hosted on a local Jetty-Server.
A component name should follow these rules, according to the long text of error message /ui5/app_api (019).
Consist only of alphanumerical characters
Contain only lowercase letters in the first except the last segment
May contain camel case in the last segment
Not begin with a number
Not contain special characters
Contain a dot as separator of the namespace
Not be longer than 40 letters for each segment (separated by a dot)
submitting to ABAP-Repository has way more strict naming conventions then mentioned in your answer. I think the application name cannot be longer then 16 signs ... otherwise you cannot submit.

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>

Replace éàçè... with equivalent "eace" In GWT

I tried
s=Normalizer.normalize(s, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "");
But it seems that GWT API doesn't provide such fonction.
I tried also :
s=s.replace("é",e);
But it doesn't work either
The scenario is I'am trying to générate token from the clicked Widget's text for the history management
You can take ASCII folding filter from Lucene and add to your project. You can just take foldToASCII() method from ASCIIFoldingFilter (the method does not have any dependencies). There is also a patch in Jira that has a full class for that without any dependencies - see here. It should be compiled by GWT without any problems. License should be also OK, since it is Apache License, but don't quote me on it - you should ask a real lawyer.
#okrasz, the foldToASCII() worked but I found a shorter one Transform a String to URL standard String in Java

GWT i18n - Plural Forms doesn't work at all?

I'm using GWT internationalization Messages. The documentation for Plural Forms says this should work:
#DefaultMessage("{0} {1,number} hours {2}")
#PluralText({"one", "an hour"})
String hours(String prefix, #PluralCount int count, String suffix);
Well, it doesn't. Whatever value of count it still delivers DefaultMessage (e.g. "1 hours ago"). Same if I use a .properties file:
hours[one]=an hour
hours[few]=some hours
hours={0} {1,number} hours {2}
Is there a bug in the docs or in GWT (I'm using GWT 2.0.3) or in me? If any of the two former, anyone knows of a workaround?
EDIT: More clues to this mystery. I can get plural handling to work if I don't rely on default locale handling. That is, I need:
In my module's gwt.xml file:
<extend-property name="locale" values="en"/>
In my Messages extentsion:
#DefaultLocale("en")
public interface MyMessages extends Messages { ...
Explicitly load the "en" locale by appending to the URL
&locale=en
See http://groups.google.com/group/google-web-toolkit/browse_thread/thread/80ae300213cc6adb where I have cross posted this question.
EDIT 2: The reason I entered this GWT plurals land is that I'm creating a "GWT HUman Readable Relative Timestamps" module. Open sourced at GitHub: http://github.com/PEZ/GWT-Relative-Time Please check it out. It'll very soon have correct singular forms and support for some languages. =)
Also I think it will save people time to know that the default English plural rule only supports "other" and "one".
DefaultRule_en.java uses DefaultRule_1_0n.java
So you have to redefine DefaultRule_en.java if you want to use "none","two",few"...
You can see the available rules in the package com.google.gwt.i18n.client.impl.plurals.
Getting used to answering my own questions =) Here's cross post of my "answer" on the GWT Google group:
There seems to be a bug with the default locale handling. Here's how I have reached that conclusion:
I wanted to add some locales to my module. Figured I could get a boiler plate for the properties file if I used the #Generate annotation. I noticed that it created both an _en.properties file and a _default.properties. What's more; the _en file completely lacked the plural form info! The _default file had them though.
I then moved the _defaults file to the same directory as my TimeMessages.java file and renamed it TimeMessages_default.properties.
With this in place I can remove <extend-property name="locale" values="en"/> from my module's .gwt.xml file and, more important, the &locale=en from the URL when running my app. I still need the #DefaultLocale("en") annotation though, even though the documentation clearly states that this is not necessary.
In conclusion, if you run into this problem, try:
generating properties files using #Generate
place YourMessages_default.properties side by side with YourMessages.java
prepend the YourMessages interface with a #DefaultLocale("en") annotation.
About that #Generate. This is what worked for me. Just before my extension of the Message interface:
#Generate(format = {"com.google.gwt.i18n.rebind.format.PropertiesFormat"})
The GWT log said it created my properties file, but I couldn't find it. I fixed that by adding the compiler flag -extra extras and then found the properties files generated in the extras directory. Including this info here since I spent more than an hour figuring it out.
Another solution from the gwt issue list here:
You have to define the #DefaultLocale in the MyMessages.java:
#DefaultLocale("en")
public interface MyMessages extends Messages {
public String items(#PluralCount #Optional int count);
}
and in MyMessages.properties:
items={0} items
items[one]=one item
One more thing I found is that you can define a fallback locale like this:
<set-property-fallback name="locale" value="en"/> in your module XML file