deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rafab...@apache.org
Subject svn commit: r1602186 - in /deltaspike/site/trunk/content: core.mdtext jsf.mdtext
Date Thu, 12 Jun 2014 14:51:40 GMT
Author: rafabene
Date: Thu Jun 12 14:51:40 2014
New Revision: 1602186

URL: http://svn.apache.org/r1602186
Log:
DELTASPIKE-227
documentation for minimal type-safe messages

Modified:
    deltaspike/site/trunk/content/core.mdtext
    deltaspike/site/trunk/content/jsf.mdtext

Modified: deltaspike/site/trunk/content/core.mdtext
URL: http://svn.apache.org/viewvc/deltaspike/site/trunk/content/core.mdtext?rev=1602186&r1=1602185&r2=1602186&view=diff
==============================================================================
--- deltaspike/site/trunk/content/core.mdtext (original)
+++ deltaspike/site/trunk/content/core.mdtext Thu Jun 12 14:51:40 2014
@@ -319,7 +319,7 @@ The following implementation uses the ke
     org/apache/deltaspike/example/message/SimpleMessage_de.properties
     ...
 
-    //content (as usual in message bundle files:
+    //content (as usual in message bundle files):
     welcome_to_deltaspike=Welcome to DeltaSpike
 
 The following implementation uses the key `welcome_to_deltaspike` to do a lookup in a custom
message bundle known by `CustomMessageResolver`.

Modified: deltaspike/site/trunk/content/jsf.mdtext
URL: http://svn.apache.org/viewvc/deltaspike/site/trunk/content/jsf.mdtext?rev=1602186&r1=1602185&r2=1602186&view=diff
==============================================================================
--- deltaspike/site/trunk/content/jsf.mdtext (original)
+++ deltaspike/site/trunk/content/jsf.mdtext Thu Jun 12 14:51:40 2014
@@ -24,7 +24,7 @@ Notice:    Licensed to the Apache Softwa
 ## Intro
 
 ### Historic Considerations
-Until the end of the 1990s web browsers are usually single threaded and only had one window.
But in the last years browsers supporting multiple windows or even tab became the standard.
Since those days lots of efforts went into uniquely identifying a single browser window on
the server side. Sadly browser windows still lack of a native windowId, thus maintaining web
application data in @SessionScoped backing beans is still used in most of the cases. 
+Until the end of the 1990s web browsers are usually single threaded and only had one window.
But in the last years browsers supporting multiple windows or even tab became the standard.
Since those days lots of efforts went into uniquely identifying a single browser window on
the server side. Sadly browser windows still lack of a native windowId, thus maintaining web
application data in @SessionScoped backing beans is still used in most of the cases.
 
 ###How JSF-2 changed the world
 
@@ -90,7 +90,7 @@ If it's not matching, the view will be r
 
 ##### Disadvantage
 
-  - It could happen that 2 tabs will share the same windowId for 1 request because the `LAZY`
mode will check lazily, after rendering the view, if the windowId matches the `window.name`.
Therefore it could happen that @ViewAccessScoped or other scopes will unintentionally be destroyed.

+  - It could happen that 2 tabs will share the same windowId for 1 request because the `LAZY`
mode will check lazily, after rendering the view, if the windowId matches the `window.name`.
Therefore it could happen that @ViewAccessScoped or other scopes will unintentionally be destroyed.
 
 #### Workflow example
 
@@ -235,6 +235,63 @@ Furthermore, the managed-bean annotation
 
 All these annotations are mapped automatically. So you won't face issues, if you import a
JSF 2 annotation instead of the corresponding CDI annotation.
 
+# Integration with DeltaSpike type-safe messages
+
+You can use [DeltaSpike type-safe messages](core.html#messages-i18n) with JSF to provide
i18n messages and test to an JSF appplicaton.
+
+JSF module is also capable to use messages provided through <message-bundle> in faces-config.xml
file. The <message-bundle> element allows you to override JSF default messages (Section
2.5.2.4 of the JSF specification contains the list of all JSF default messages that could
be override.).
+
+You can also use the same file to provide type-safe messages.
+
+Example:
+
+    :::java
+    @MessageBundle
+    public interface SimpleMessage
+    {
+        @MessageTemplate("{welcome_to_deltaspike}")
+        String welcomeToDeltaSpike();
+    }
+
+    @Model
+    public class PageBean
+    {
+
+        @Inject
+        private SimpleMessage messages;
+
+        public void actionMethod(){
+            FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(messages.welcomeToDeltaSpike()));
+        }
+
+    }
+
+
+    org.apache.deltaspike.example.message.SimpleMessage
+
+    ->
+
+    org/apache/deltaspike/example/message/SimpleMessage.properties
+    org/apache/deltaspike/example/message/SimpleMessage.properties
+    org/apache/deltaspike/example/message/SimpleMessage_en.properties
+    org/apache/deltaspike/example/message/SimpleMessage_de.properties
+
+    ...
+
+    //content (as usual in message bundle files):
+    welcome_to_deltaspike=Welcome to DeltaSpike
+    //Overrided JSF messages
+    javax.faces.component.UIInput.REQUIRED = {0}: Please enter a value
+
+On faces-config.xml file:
+
+    <faces-config>
+        <application>
+            <message-bundle>org.apache.deltaspike.example.message.SimpleMessage</message-bundle>
+        </application>
+    </faces-config>
+
+
 # Type-safe View-Configs
 
 ## Intro
@@ -491,7 +548,7 @@ and depending on additional meta-data yo
 
     :::java
     @View(navigation = REDIRECT)
-    interface Pages extends ViewConfig 
+    interface Pages extends ViewConfig
     {
         interface Wizard1 extends Pages
         {
@@ -758,7 +815,7 @@ In case of
     }
 
 it's possible to navigate with `DefaultErrorView.class` instead of hardcoding it to `Pages.CustomErrorPage.class`.
-    
+
     :::java
     @Model
     public class PageController
@@ -1008,7 +1065,7 @@ Example - Separated DeltaSpike conversat
     {
         //...
     }
- 
+
     @GroupedConversationScoped
     public class DemoBean3 implements Serializable
     {
@@ -1023,14 +1080,14 @@ Example - Grouped conversation scoped be
 
     :::java
     interface Wizard1 {}
- 
+
     @GroupedConversationScoped
     @ConversationGroup(Wizard1.class)
     public class DemoBean4 implements Serializable
     {
         //...
     }
- 
+
     @GroupedConversationScoped
     @ConversationGroup(Wizard1.class)
     public class DemoBean5 implements Serializable
@@ -1049,7 +1106,7 @@ Example - Injecting a conversation scope
         @Inject
         @ConversationGroup(Group1.class)
         private CustomBean2 demoBean;
- 
+
         @Inject
         @ConversationGroup(Group2.class)
         private CustomBean2 demoBean;
@@ -1062,7 +1119,7 @@ Example - Producer methods which produce
     :::java
     interface Group1 {}
     interface Group2 {}
- 
+
     public class CustomBean2
     {
         @Produces
@@ -1072,7 +1129,7 @@ Example - Producer methods which produce
         {
             return new CustomBean2();
         }
- 
+
         @Produces
         @GroupedConversationScoped
         @ConversationGroup(Group2.class)
@@ -1094,23 +1151,23 @@ Example - Injecting and using the curren
     {
         @Inject
         private GroupedConversation conversation; //injects the conversation of DemoBean6
(!= conversation of DemoBean7)
- 
+
         //...
- 
+
         public void finish()
         {
             this.conversation.close();
         }
     }
- 
+
     @GroupedConversationScoped
     public class DemoBean7 implements Serializable
     {
         @Inject
         private GroupedConversation conversation; //injects the conversation of DemoBean7
(!= conversation of DemoBean6)
- 
+
         //...
- 
+
         public void finish()
         {
             this.conversation.close();
@@ -1121,16 +1178,16 @@ Example - Injecting and using the explic
 
     :::java
     interface Wizard2 {}
- 
+
     @GroupedConversationScoped
     @ConversationGroup(Wizard2.class)
     public class DemoBean8 implements Serializable
     {
         @Inject
         private GroupedConversation conversation; //injects the conversation of Wizard2 (contains
DemoBean8 and DemoBean9)
- 
+
         //...
- 
+
         public void finish()
         {
             this.conversation.close();
@@ -1143,9 +1200,9 @@ Example - Injecting and using the explic
     {
         @Inject
         private GroupedConversation conversation; //injects the conversation of Wizard2 (contains
DemoBean8 and DemoBean9)
- 
+
         //...
- 
+
         public void finish()
         {
             this.conversation.close();
@@ -1160,9 +1217,9 @@ Example - Terminating a grouped conversa
     {
         @Inject
         private GroupedConversationManager conversationManager;
- 
+
         //...
- 
+
         public void finish()
         {
             this.conversationManager.closeConversationGroup(Wizard2.class);  //closes the
conversation of group Wizard2.class
@@ -1177,9 +1234,9 @@ Example - Terminate all conversations:
     {
         @Inject
         private GroupedConversationManager conversationManager;
- 
+
         //...
- 
+
         public void finish()
         {
             this.conversationManager.closeConversations();  //closes all existing conversations
within the current window (context)
@@ -1198,24 +1255,24 @@ Example - Explicitly listing beans of a 
 
     :::java
     public class MyGroup{}
- 
+
     @GroupedConversationScoped
     @ConversationGroup(MyGroup.class)
     public class BeanA {}
- 
+
     @GroupedConversationScoped
     @ConversationGroup(MyGroup.class)
     public class BeanB {}
- 
+
     @GroupedConversationScoped
     @ConversationGroup(MyGroup.class)
     public class BeanC {}
- 
+
     @ConversationSubGroup(subGroup = {BeanA.class, BeanB.class})
     public class MySubGroup extends MyGroup {}
- 
+
     //or
- 
+
     @ConversationSubGroup(of = MyGroup.class, subGroup = {BeanA.class, BeanB.class})
     public class MySubGroup {}
 
@@ -1236,12 +1293,12 @@ Example - Implicit sub-group:
 
     :::java
     public interface Wizard {}
- 
+
     @ConversationSubGroup(of = MyGroup.class, subGroup = Wizard.class)
     public class ImplicitSubGroup
     {
     }
- 
+
     @Named("myWizard")
     @GroupedConversationScoped
     @ConversationGroup(MyGroup.class)
@@ -1249,7 +1306,7 @@ Example - Implicit sub-group:
     {
         //...
     }
- 
+
     this.conversationManager.closeConversationGroup(ImplicitSubGroup.class);
 
 In the listing above all beans which implement the Wizard interface will be closed as soon
as you close the ImplicitSubGroup.



Mime
View raw message