Friday, March 7, 2014

Re: in GWT, can we manage Messages & Constants (i18n) at Server as we manage at Client?



On Friday, March 7, 2014 9:33:26 AM UTC+1, Tom wrote:

Messages & Constants (com.google.gwt.i18n.client.Constants & com.google.gwt.i18n.client.Messages) in GWT allow us to put all Messages & Constants into properties files so that we can change these messages & constants at any time we want without the need to recompile the whole webapp when we need to change them.

Wrong assumption. You'll have to recompile your app whenever you change anything related to client-side code.
 

Ex: you have a message call "User451 pls views order" in myMessages.properties

userViewOrder=User''{0}'' pls views order

& in the MyMessages.java

public interface MyMessages extends Messages{      String userViewOrder(String userID);  }

At a later time, the bos wants to change the message to "Customer451 pls views order" then we don't need to recompile the whole project but just need to modify the myMessages.properties file

userViewOrder=Customer''{0}'' pls views order

So my question is, can we achieve the similar thing at the server level?

For example, in server, after inserting order data successfully into DB we need to send a private message to the customer immediately right at the server. Ex:

public boolean isertOrder(String data, String userID){      String sql="insert query here";      ..... more code ....      int resultCode=prepareStmt.executeUpdate();      if (resultCode==1){         //insert a notification into Message table          String msg="Congratulation user "+userID+", You ordered successfully!";   // how to manage this message without needing to recompiling the whole project           String sql="insert into Message values (.....)"         ///do the inserting here      }  }

can we manage Messages & Constants (i18n) at Server as we manage at Client?

Note that you'll have to make sure that your *.properties files are US-ASCII, as GWT expects them in UTF-8 and ResourceBundle as ISO-8859-1. You can use a custom ResourceBundle.Control to load them as UTF-8.
And then use MessageFormat for replacing placeholders (for the case of c.g.g.i18n.client.Messages).

That said, there also are existing GWT-like solutions, such as https://github.com/dbaeli/ez18n (see http://fr.slideshare.net/gdigugli/con11234-baeli-diguglielmo)
There are also a few projects that directly try to use your GWT interfaces on server-side; and it's also a planned feature of GWT proper (no ETA yet).

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment