Return-Path: X-Original-To: apmail-deltaspike-commits-archive@www.apache.org Delivered-To: apmail-deltaspike-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 31458176D7 for ; Tue, 27 Oct 2015 19:05:33 +0000 (UTC) Received: (qmail 57971 invoked by uid 500); 27 Oct 2015 19:05:26 -0000 Delivered-To: apmail-deltaspike-commits-archive@deltaspike.apache.org Received: (qmail 57936 invoked by uid 500); 27 Oct 2015 19:05:26 -0000 Mailing-List: contact commits-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltaspike.apache.org Delivered-To: mailing list commits@deltaspike.apache.org Received: (qmail 57927 invoked by uid 99); 27 Oct 2015 19:05:26 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Oct 2015 19:05:26 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id E1E91C8114 for ; Tue, 27 Oct 2015 19:05:25 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.748 X-Spam-Level: *** X-Spam-Status: No, score=3.748 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.001, URIBL_BLOCKED=0.001, URIBL_JP_SURBL=1.948] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Mi_O8O36OaZO for ; Tue, 27 Oct 2015 19:05:19 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id B4A3E21436 for ; Tue, 27 Oct 2015 19:05:18 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 1447DE0E95 for ; Tue, 27 Oct 2015 19:05:18 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 108013A0B6B for ; Tue, 27 Oct 2015 19:05:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r970404 [2/3] - in /websites/staging/deltaspike/trunk/content: ./ staging/documentation/ Date: Tue, 27 Oct 2015 19:05:17 -0000 To: commits@deltaspike.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151027190518.108013A0B6B@svn01-us-west.apache.org> Modified: websites/staging/deltaspike/trunk/content/staging/documentation/jsf.html ============================================================================== --- websites/staging/deltaspike/trunk/content/staging/documentation/jsf.html (original) +++ websites/staging/deltaspike/trunk/content/staging/documentation/jsf.html Tue Oct 27 19:05:17 2015 @@ -437,9 +437,9 @@ not feasible as general solution.

Each GET request results in an intermediate small html page which checks if the browser tab fits the requested windowId. When the windowId is -valid, a unique token (called dsRid) will be generated for the current +valid, a unique token (called dsrid) will be generated for the current request and added to the URL. In addition a cookie with with the -dsRid/windowId will be added. On the server side, the verified windowId +dsrid/dswid will be added. On the server side, the verified windowId will be extracted from the cookie. For POST request detection, the windowId will be added as hidden input to all forms.

@@ -477,10 +477,12 @@ directly.

-
Change windowhandler.html
+
Configuration
+
+
Reduce windowhandler.html flickering
-

To customize the look and feel of the windowhandler.html, you can simply -provide a own via:

+

Per default we only overwrite the onclick events of all links on the current page to make a 'screenshot' between requests. +We also provide a mechanism to store the 'screenshot' on ajax requests (e.g. Post-Redirect-Get via p:remoteCommand or other components) or on every button onclick:

@@ -488,298 +490,308 @@ provide a own via:

public class MyClientWindowConfig extends DefaultClientWindowConfig { @Override - public String getClientWindowHtml() + public boolean isClientWindowStoreWindowTreeEnabledOnAjaxRequest() { - return "<html><body>Loading...</body></html>"; + return true; } -} -
-
+ + @Override + public boolean isClientWindowStoreWindowTreeEnabledOnButtonClick() + { + return true; + } +} + +====== Change windowhandler.html + +To customize the look and feel of the windowhandler.html, you can simply +provide a own via: + +[source,java]
-
-

LAZY

-

Always appends the windowId to all, from JSF generated, URLs. On the -first GET request without a windowId, it will generate a new windowId -and redirect, with the windowId in the URL, to the same view again. The -current windowId will be stored in the window.name variable on the -client side. For all further requests, a lazy check will be performed to -check if the windowId in the URL is matching with the window.name. If -it is not matching, the view will be refreshed with the right windowId in -the URL.

-
-
-
Advantage
-
-
    -
  • -

    No windowhandler.html / loading screen required

    -
  • -
-
-
-
-
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.

    -
  • -
-
+

@Specializes +public class MyClientWindowConfig extends DefaultClientWindowConfig +{ + @Override + public String getClientWindowHtml() + { + return "<html><body>Loading…​</body></html>"; + } +}

-
-
Workflow Example
-
-

First GET request with windowId

+
+
+
If you didn't copy the JS logic from our default windowhandler.html or
+if you would like to always show your custom html instead the 'screenshot', you should disable logic via:
+
+[source,java]
-
-
    -
  • -

    Renders the view

    -
  • -
  • -

    Stores the windowId as window.name on the client side

    -
  • -
-

First GET request without windowId

-
-
-
    -
  • -

    Redirect to the same view with a new windowId in the URL

    -
  • -
  • -

    Renders the view

    -
  • -
  • -

    Stores the windowId as window.name on the client side

    -
  • -
+

@Specializes +public class MyClientWindowConfig extends DefaultClientWindowConfig +{ + @Override + public boolean isClientWindowStoreWindowTreeEnabledOnLinkClick() + { + return false; + }

-
-

Further GET request with windowId

+
+
+
@Override
+public boolean isClientWindowStoreWindowTreeEnabledOnAjaxRequest()
+{
+    return false;
+}
-
-
    -
  • -

    Renders the view

    -
  • -
  • -

    Checks if the requested windowId matches the window.name

    -
  • -
  • -

    If it does not match, reload the URL with the right windowId taken -from window.name

    -
  • -
-
-

Further GET request without windowId

+
+
+
    @Override
+    public boolean isClientWindowStoreWindowTreeEnabledOnButtonClick()
+    {
+        return false;
+    }
+}
-
-
    -
  • -

    Redirect to the same view with a new windowId in the URL

    -
  • -
  • -

    Renders the view

    -
  • -
  • -

    If it does not match, reload the URL with the right windowId taken -from window.name

    -
  • -
+
+
+
====== Minimize windowhandler.html streaming
+
+It's possible to reduce the windowhandler.html streaming if we overwrite the onclick event of all links to mark the next request as 'valid'.
+The onclick handler appends a request token to the URL and creates a cookie for the request token.
+
+You can enable this via:
+
+[source,java]
-
-

NONE

-

Any window or browser tab detection will be disabled for the current +

@Specializes +public class MyClientWindowConfig extends DefaultClientWindowConfig +{ + @Override + public String isClientWindowTokenizedRedirectEnabled() + { + return true; + } +}

+
+
+
+
==== LAZY
+
+Always appends the windowId to all, from JSF generated, URLs. On the
+first GET request without a windowId, it will generate a new windowId
+and redirect, with the windowId in the URL, to the same view again. The
+current windowId will be stored in the `window.name` variable on the
+client side. For all further requests, a lazy check will be performed to
+check if the windowId in the URL is matching with the `window.name`. If
+it is not matching, the view will be refreshed with the right windowId in
+the URL.
+
+
+===== Advantage
+
+* No windowhandler.html / loading screen required
+
+===== 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.
+
+
+===== Workflow Example
+
+First GET request with windowId
+
+* Renders the view
+* Stores the windowId as `window.name` on the client side
+
+
+First GET request without windowId
+
+* Redirect to the same view with a new windowId in the URL
+* Renders the view
+* Stores the windowId as `window.name` on the client side
+
+
+Further GET request with windowId
+
+* Renders the view
+* Checks if the requested windowId matches the `window.name`
+* If it does not match, reload the URL with the right windowId taken
+from `window.name`
+
+
+Further GET request without windowId
+
+* Redirect to the same view with a new windowId in the URL
+* Renders the view
+* If it does not match, reload the URL with the right windowId taken
+from `window.name`
+
+
+==== NONE
+
+Any window or browser tab detection will be disabled for the current
 request. Scopes like @WindowScoped, @GroupedConversationScoped or
 @ViewAccessScoped will not work. This is also the default mode if the
 current request does not support Javascript or if the user agent is a
-bot/crawler.

-
-
-
-

DELEGATED

-
-

Delegates the complete window handling to the new JSF 2.2 ClientWindow -(if not disabled).

-
-
-
-

CUSTOM

-
-

Enables to use an complete own -org.apache.deltaspike.jsf.spi.scope.window.ClientWindow -implementation.

-
-
-
-
-

Configuration

-
-

ds:windowId

-
-

The component ds:windowId -(xmlns:ds="http://deltaspike.apache.org/jsf") is required to enable +bot/crawler. + + +==== DELEGATED + +Delegates the complete window handling to the new JSF 2.2 ClientWindow +(if not disabled). + + +==== CUSTOM + +Enables to use an complete own +`org.apache.deltaspike.jsf.spi.scope.window.ClientWindow` +implementation. + + +=== Configuration + +==== ds:windowId + +The component `ds:windowId` +(`xmlns:ds="http://deltaspike.apache.org/jsf"`) is required to enable the full control of the DeltaSpike window handling. It will import and -render the required script parts for both LAZY and CLIENTWINDOW +render the required script parts for both `LAZY` and `CLIENTWINDOW` mode. The best way, to apply it for all views, is to add this component -to all of your templates.

-
-
-
-

ds:disableClientWindow

-
-

Similiar to JSF 2.2' disableClientWindow attribute, -ds:disableClientWindow provides the ability to disable the rendering -of the windowId to all links of all child components:

-
-
-
-
<ds:disableClientWindow>
-    <h:link value="Link without windowId" outcome="target.xhtml" />
-</ds:disableClientWindow>
-<h:link value="Link with windowId" outcome="target.xhtml"/>
-
-
-
-
-

Number of Active Windows

-
-

By default, DeltaSpike allows 1024 active windows per session. Anyway, this number is reduced inside this JSF module to 64 for JSF applications. Once that the limit number of active windows is reached, DeltaSpike will drop the oldest active window.

+to all of your templates. + + +==== ds:disableClientWindow + +Similiar to JSF 2.2' `disableClientWindow` attribute, +`ds:disableClientWindow` provides the ability to disable the rendering +of the windowId to all links of all child components: + +[source,xml]
-
-

You can change the default value by setting the property deltaspike.scope.window.max-count using DeltaSpike configuration mechanism.

-

You can also provide this value via:

+

<ds:disableClientWindow> + <h:link value="Link without windowId" outcome="target.xhtml" /> +</ds:disableClientWindow> +<h:link value="Link with windowId" outcome="target.xhtml"/>

-
@Specializes
-public class MyClientWindowConfig extends DefaultClientWindowConfig
+
==== Number of Active Windows
+
+By default, DeltaSpike allows `1024` active windows per session. Anyway, this number is reduced inside this JSF module to `64` for JSF applications. Once that the limit number of active windows is reached, DeltaSpike will drop the oldest active window.
+
+You can change the default value by setting the property `deltaspike.scope.window.max-count` using  <<configuration.adoc#_configsources_provided_by_default, DeltaSpike configuration mechanism>>.
+
+You can also provide this value via:
+
+[source,java]
+-----------------------------------------------------------------------------------
+@Specializes
+public class MyClientWindowConfig extends DefaultClientWindowConfig
 {
 
-    @Override
-    public int getMaxWindowContextCount()
+    @Override
+    public int getMaxWindowContextCount()
     {
-        // return the max active windows per session
+        // return the max active windows per session
     }
-}
-
-
-
-
-

Switch Mode

-
-

To switch the mode, just provide a -org.apache.deltaspike.jsf.api.config.JsfModuleConfig and overwrite -#getDefaultWindowMode:

-
-
-
-
@Specializes
-public class MyJsfModuleConfig extends JsfModuleConfig
+}
+-----------------------------------------------------------------------------------
+
+==== Switch Mode
+
+To switch the mode, just provide a
+`org.apache.deltaspike.jsf.api.config.JsfModuleConfig` and overwrite
+`#getDefaultWindowMode`:
+
+[source,java]
+---------------------------------------------------------------------------
+@Specializes
+public class MyJsfModuleConfig extends JsfModuleConfig
 {
-    @Override
-    public ClientWindowConfig.ClientWindowRenderMode getDefaultWindowMode()
+    @Override
+    public ClientWindowConfig.ClientWindowRenderMode getDefaultWindowMode()
     {
-        //...
+        //...
     }
-}
-
-
-
-
-

Provide a Custom ClientWindow

-
-

If you would like to provide an custom -org.apache.deltaspike.jsf.spi.scope.window.ClientWindow -implementation, you can just do it, for example, via CDI alternatives:

-
-
-
-
@ApplicationScoped
-public class MyClientWindow implements ClientWindow
+}
+---------------------------------------------------------------------------
+
+
+==== Provide a Custom ClientWindow
+
+If you would like to provide an custom
+`org.apache.deltaspike.jsf.spi.scope.window.ClientWindow`
+implementation, you can just do it, for example, via CDI alternatives:
+
+[source,java]
+---------------------------------------------------
+@ApplicationScoped
+public class MyClientWindow implements ClientWindow
 {
-    //...
-}
-
-
-
-

Do not forget to set the ClientWindowRenderMode to 'CUSTOM' via the -JsfModuleConfig:

-
-
-
-
@Specializes
-public class MyJsfModuleConfig extends JsfModuleConfig
+    //...
+}
+---------------------------------------------------
+
+Do not forget to set the `ClientWindowRenderMode` to 'CUSTOM' via the
+`JsfModuleConfig`:
+
+[source,java]
+---------------------------------------------------------------------------
+@Specializes
+public class MyJsfModuleConfig extends JsfModuleConfig
 {
-    @Override
-    public ClientWindowConfig.ClientWindowRenderMode getDefaultWindowMode()
+    @Override
+    public ClientWindowConfig.ClientWindowRenderMode getDefaultWindowMode()
     {
-        return ClientWindowConfig.ClientWindowRenderMode.CUSTOM;
+        return ClientWindowConfig.ClientWindowRenderMode.CUSTOM;
     }
-}
-
-
-
-
-
-

Based Scopes

-
-
    -
  • -

    @WindowScoped

    -
  • -
  • -

    @ViewAccessScoped

    -
  • -
  • -

    @GroupedConversationScoped

    -
  • -
-
-
-
-
-
-

Scopes

-
-
-

@WindowScoped

-
-

The window-scope is like a session per window. That means that the data +} +--------------------------------------------------------------------------- + +=== Based Scopes + +* @WindowScoped +* @ViewAccessScoped +* @GroupedConversationScoped + + +== Scopes + +=== @WindowScoped + +The window-scope is like a session per window. That means that the data is bound to a window/tab and it not shared between windows (like the session scope does). Usually you need the window-scope instead of the session-scope. There areis not a lot of use-cases which need shared data -between windows.

-
-
-
-
@WindowScoped
-public class PreferencesBean implements Serializable
+between windows.
+
+[source,java]
+----------------------------------------------------
+@WindowScoped
+public class PreferencesBean implements Serializable
 {
-    //...
-}
-
-
-
-
-

@ViewAccessScoped

-
-

In case of conversations you have to un-scope beans manually (or they + //... +} +---------------------------------------------------- + + +=== @ViewAccessScoped + +In case of conversations you have to un-scope beans manually (or they will be terminated automatically after a timeout). However, sometimes you need beans with a lifetime which is as long as needed and as short as possible - which are terminated automatically (as soon as possible). @@ -788,122 +800,86 @@ as the bean is referenced by a page - th next page (if it is used again the bean will be forwarded again). It is important that it is based on the view-id of a page (it is not based on the request) so, for example, Ajax requests do not trigger a cleanup if the -request does not access all view-access scoped beans of the page. That’s -also the reason for the name @ViewAccessScoped.

-
-
-
-
@ViewAccessScoped
-public class WizardBean implements Serializable
+request does not access all view-access scoped beans of the page. That's
+also the reason for the name @__View__AccessScoped.
+
+[source,java]
+-----------------------------------------------
+@ViewAccessScoped
+public class WizardBean implements Serializable
 {
-    //...
-}
-
-
-
- - - - - -
- - -@ViewAccessScoped beans are best used in conjunction with the -CLIENTWINDOW window handling, which ensures a clean browser-tab + //... +} +----------------------------------------------- + +TIP: @ViewAccessScoped beans are best used in conjunction with the +`CLIENTWINDOW` window handling, which ensures a clean browser-tab separation without touching the old windowId. Otherwise a 'open in new tab' on a page with a @ViewAccessScoped bean might cause the termination (and re-initialization) of that bean. -
-
-
-
-

@GroupedConversationScoped

-
-

See (Grouped-)Conversations

-
-
-
-

@ViewScoped

-
-

DeltaSpike provides an CDI context for the JSF 2.0/2.1 + +=== @GroupedConversationScoped + +See (Grouped-)Conversations + +=== @ViewScoped + +DeltaSpike provides an CDI context for the JSF 2.0/2.1 @javax.faces.bean.ViewScoped. You can simply annotate your bean with -@javax.faces.bean.ViewScoped and @Named.

-
-
-
-

JSF 2.0 Scopes

-
-

JSF 2.0 introduced new annotations as well as a new scope - the View -Scope. CODI allows to use all the CDI mechanisms in beans annotated -with:

-
-
-
    -
  • -

    javax.faces.bean.ApplicationScoped

    -
  • -
  • -

    javax.faces.bean.SessionScoped

    -
  • -
  • -

    javax.faces.bean.RequestScoped

    -
  • -
  • -

    javax.faces.bean.ViewScoped

    -
  • -
-
-
-

Furthermore, the managed-bean annotation (javax.faces.bean.ManagedBean) -is mapped to @Named from CDI.

-
-
-

All these annotations are mapped automatically. So you will not face +@javax.faces.bean.ViewScoped and @Named. + +=== JSF 2.0 Scopes + +JSF 2.0 introduced new annotations as well as a new scope - the View +Scope. DeltaSpike allows to use all the CDI mechanisms in beans annotated +with: + +* javax.faces.bean.ApplicationScoped +* javax.faces.bean.SessionScoped +* javax.faces.bean.RequestScoped +* javax.faces.bean.ViewScoped + +Furthermore, the managed-bean annotation (javax.faces.bean.ManagedBean) +is mapped to @Named from CDI. + +All these annotations are mapped automatically. So you will not 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 -with JSF to provide i18n messages and test to an JSF appplicaton.

-
-
-

JSF module is also capable to use messages provided through in +CDI annotation. + +== Integration with DeltaSpike Type-safe Messages + +You can use <<core.adoc#_messages_i18n,DeltaSpike type-safe messages>> +with JSF to provide i18n messages and test to an JSF appplicaton. + +JSF module is also capable to use messages provided through in faces-config.xml file. The 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.).

-
-
-

DeltaSpike can also reuse the same file to provide type-safe messages so -you do not have to use the naming convention nor @MessageContextConfig. +all JSF default messages that could be override.). + +DeltaSpike can also reuse the same file to provide type-safe messages so +you do not have to use the naming convention nor `@MessageContextConfig`. If there is a config for supported locales it will be checked as well -and fallback to the configured default locale.

-
-
-
Example
-
-
@MessageBundle
-public interface SimpleMessage
+and fallback to the configured default locale.
+
+.Example
+[source,java]
+------------------------------------------------------------------------------------------------------------
+@MessageBundle
+public interface SimpleMessage
 {
-    @MessageTemplate("{welcome_to_deltaspike}")
-    String welcomeToDeltaSpike();
+    @MessageTemplate("{welcome_to_deltaspike}")
+    String welcomeToDeltaSpike();
 }
 
-@Model
-public class PageBean
+@Model
+public class PageBean
 {
 
-    @Inject
-    private SimpleMessage messages;
+    @Inject
+    private SimpleMessage messages;
 
-    public void actionMethod(){
-        FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(messages.welcomeToDeltaSpike()));
+    public void actionMethod(){
+        FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(messages.welcomeToDeltaSpike()));
     }
 
 }
@@ -920,1479 +896,1254 @@ org/apache/deltaspike/example/message/Si
 
 ...
 
-//content (as usual in message bundle files):
+//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
-
-
-
-
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

-
-

Type-safe view-configs are static configs which can be used in +//Overrided JSF messages +javax.faces.component.UIInput.REQUIRED = {0}: Please enter a value +------------------------------------------------------------------------------------------------------------ + +.Faces-config.xml File +[source,xml] +-------------------------------------------------------------------------------------------- +<faces-config> + <application> + <message-bundle>org.apache.deltaspike.example.message.SimpleMessage</message-bundle> + </application> +</faces-config> +-------------------------------------------------------------------------------------------- + +== Type-safe View-Configs + +=== Intro + +Type-safe view-configs are static configs which can be used in combination with every view-technology which is based on Java. Currently DeltaSpike itself provides an integration for JSF, however, the basic concepts are independent of it. (Since DeltaSpike provides the default integration only for JSF, the whole documentation for view-configs is -located here.)

-
-
-

Thanks to features like multiple (meta-data-)inheritance via interfaces, +located here.) + +Thanks to features like multiple (meta-data-)inheritance via interfaces, it provides a powerful approach to bind meta-data to one or multiple views. In case of the JSF integration it is possible to provide, for example, type-safe meta-data for security, navigation, callbacks for view-controllers. Beyond configuring view (/pages) via this concept, it is also possible to use the (view-)config classes for type-safe navigation. Since it is standard Java, you can benefit from any Java-IDE and -you do not need special IDE-Addons to use it efficiently.

-
-
-

Even the concepts provided by modules (of DeltaSpike itself) are based +you do not need special IDE-Addons to use it efficiently. + +Even the concepts provided by modules (of DeltaSpike itself) are based on the basic API provided by the Core. So it is possible to introduce -custom concepts the same way DeltaSpike itself does.

-
-
-
-

Motivation

-
-

Instead of learning the concepts and rules of view-configs provided by +custom concepts the same way DeltaSpike itself does. + +=== Motivation + +Instead of learning the concepts and rules of view-configs provided by DeltaSpike, it might be easier for simple demos to just type some simple(r) strings. So why should you use something which is slightly -more work initially?

-
-
-

The short answer is: It gives a good return in case of real applications (especially beyond simple demos).

-
-
-

The long answer is: You can benefit from it from the first second:

-
-
-
    -
  • -

    It is type-safe

    -
    -
      -
    • -

      the Java compiler ensures that you do not have typos at the final usages (and the rest can be checked during bootstrapping of the application)

      -
    • -
    • -

      you can benefit from the auto.complete features of any modern Java IDE.

      -
    • -
    -
    -
  • -
  • -

    If you change the name of a file/folder, you need only one (easy) code-change in a single place and your (standard Java-) IDE will do the rest for you (= update all usages) without a special plug-in

    -
  • -
  • -

    It is possible to restrict the navigation target → you can ensure that the navigation target is still the intended one (e.g. after a refactoring)

    -
  • -
  • -

    You can configure meta-data in a central place (which can get inherited via multiple inheritance based on Java interfaces)

    -
  • -
  • -

    Easier for developers to find usages

    -
  • -
  • -

    Allows easy(er) refactorings and maintenance

    -
  • -
  • -

    You can use your IDE more efficiently especially in large projects (there are some users who initially switched to it, because their tools for displaying the config they had before open large config files very slowly…​)

    -
  • -
  • -

    Modern Java IDEs show inheritance of interfaces and classes in a nice way. Since the view-config is based on standard classes and interfaces, you can benefit from it easily.

    -
  • -
-
-
-

Advantages which are planned for later (= currently not supported):

-
-
-
    -
  • -

    It is possible to check if the configured folders and files really exist during/after the bootstrapping phase of the application (currently it is not implemented, but it is possible to do it).

    -
  • -
  • -

    It is also easy(er) for tools (IDE plugins,…​) to validate it

    -
  • -
  • -

    It is possible to validate the config (if the corresponding path (view or folder) really exists (after v0.5 it is done out-of-the-box)

    -
  • -
-
-
-

If you are still not convinced, you just have to try it. You will see how your daily workflow benefits from it pretty soon.

-
-
-
-

Bean-discovery-mode Annotated

-
-

CDI 1.1 introduced a concept called bean-discovery-mode. If you would -like to use the mode annotated, please have a look at the tip at -@ViewConfigRoot

-
-
-
-

Basic API Usages

-
-

While reading this section keep the following simple rules in mind: +more work **initially**? + +*The short answer is:* It gives a good return in case of real applications (especially beyond simple demos). + +*The long answer is:* You can benefit from it from the first second: + +* It is type-safe +** the Java compiler ensures that you do not have typos at the final usages (and the rest can be checked during bootstrapping of the application) +** you can benefit from the auto.complete features of any modern Java IDE. +* If you change the name of a file/folder, you need only one (easy) code-change in a single place and your (standard Java-) IDE will do the rest for you (= update all usages) without a special plug-in +* It is possible to restrict the navigation target -> you can ensure that the navigation target is still the intended one (e.g. after a refactoring) +* You can configure meta-data in a central place (which can get inherited via *multiple* inheritance based on Java interfaces) +* Easier for developers to find usages +* Allows easy(er) refactorings and maintenance +* You can use your IDE more efficiently especially in large projects (there are some users who initially switched to it, because their tools for displaying the config they had before open large config files very slowly...) +* Modern Java IDEs show inheritance of interfaces and classes in a nice way. Since the view-config is based on standard classes and interfaces, you can benefit from it easily. + +Advantages which are planned for later (= currently not supported): + +* It is possible to check if the configured folders and files really exist during/after the bootstrapping phase of the application (currently it is not implemented, but it is possible to do it). +* It is also easy(er) for tools (IDE plugins,...) to validate it +* It is possible to validate the config (if the corresponding path (view or folder) really exists (after v0.5 it is done out-of-the-box) + +If you are still not convinced, you just have to try it. You will see how your daily workflow benefits from it pretty soon. + +=== Bean-discovery-mode Annotated + +CDI 1.1 introduced a concept called bean-discovery-mode. If you would +like to use the mode `annotated`, please have a look at the tip at +@ViewConfigRoot + +=== Basic API Usages + +While reading this section keep the following simple rules in mind: Meta-data gets inherited along the path of Java inheritance -File-/Folder- paths are build based on nesting classes and interfaces -Usually users do not need to be aware of all descriptors, SPIs,…​ which -are described by this documentation.

-
-
-

There are a lot of possibilities to configure views and some of them are +File-/Folder- paths are build based on nesting classes and interfaces +Usually users do not need to be aware of all descriptors, SPIs,... which +are described by this documentation. + +There are a lot of possibilities to configure views and some of them are optional. The following examples show some of them in combination with -features provided by the JSF- and Security-Module of DeltaSpike.

-
-
-

The following example shows the minimal syntax for providing a config -for a view (/page).

-
-
-
-
public class MyPage implements ViewConfig
+features provided by the JSF- and Security-Module of DeltaSpike.
+
+The following example shows the minimal syntax for providing a config
+for a view (/page).
+
+[source,java]
+-----------------------------------------
+public class MyPage implements ViewConfig
 {
-}
-
-
-
-

Since it is a class (and not an interface), it is automatically recognized as +} +----------------------------------------- + +Since it is a class (and not an interface), it is automatically recognized as config for a page (and not a folder) and the default settings get applied during bootstrapping. In case of JSF you can use it for -navigation, for example, via action-methods.

-
-
-
-
public Class<? extends ViewConfig> toNextPage()
+navigation, for example, via action-methods.
+
+[source,java]
+-----------------------------------------------
+public Class<? extends ViewConfig> toNextPage()
 {
-    return MyPage.class;
-}
-
-
-
-

This leads to a forward to /myPage.xhtml. Information like base-path, + return MyPage.class; +} +----------------------------------------------- + +This leads to a forward to `/myPage.xhtml`. Information like base-path, file- (and folder-)name/s, file-extension, navigation mode, -view-params,…​ can be customized with the corresponding +view-params,... can be customized with the corresponding (meta-data-)annotations. One of those annotations provided by the JSF -module (which is optional) is @View. That means the following example -leads to the same as the first one.

-
-
-
-
@View //optional
-public class MyPage implements ViewConfig
+module (which is optional) is `@View`. That means the following example
+leads to the same as the first one.
+
+[source,java]
+-----------------------------------------
+@View //optional
+public class MyPage implements ViewConfig
 {
-}
-
-
-
-

But it is also possible to reflect the folder structure via nesting of -interfaces and classes. An example for it is:

-
-
-
-
public interface Pages
+}
+-----------------------------------------
+
+But it is also possible to reflect the folder structure via nesting of
+interfaces and classes. An example for it is:
+
+[source,java]
+------------------------------------------
+public interface Pages
 {
-    class Index implements ViewConfig { }
+    class Index implements ViewConfig { }
 
-    interface AdminArea extends ViewConfig
+    interface AdminArea extends ViewConfig
     {
-        class Index implements Admin { }
+        class Index implements Admin { }
     }
-}
-
-
-
-

In case of the JSF integration it leads to the following view-ids: -/pages/index.xhtml /pages/adminArea/index.xhtml

-
-
-

Like the optional @View for pages represented by the classes, it is -possible to use the optional @Folder annotation for directories -represented by the (nested) interfaces.

-
-
-

Furthermore, it is possible to inherit meta-data along with the normal -inheritance.

-
-
-

In the following example Pages.Admin.Index, Pages.Admin.Home and -Pages.Admin.Statistics.Home inherit the meta-data from Pages.Admin +} +------------------------------------------ + +In case of the JSF integration it leads to the following view-ids: +/pages/index.xhtml /pages/adminArea/index.xhtml + +Like the optional `@View` for pages represented by the classes, it is +possible to use the optional `@Folder` annotation for directories +represented by the (nested) interfaces. + +Furthermore, it is possible to inherit meta-data along with the normal +inheritance. + +In the following example `Pages.Admin.Index`, `Pages.Admin.Home` and +`Pages.Admin.Statistics.Home` inherit the meta-data from `Pages.Admin` because they implement the interface whereas -Pages.Admin.Statistics.Index does not. However, Pages.Admin.Home -overrides View#navigation. During the bootstrapping process the +`Pages.Admin.Statistics.Index` does not. However, `Pages.Admin.Home` +overrides `View#navigation`. During the bootstrapping process the meta-data gets merged and at runtime you only see the final result -(which is cached).

-
-
-
-
public interface Pages
+(which is cached).
+
+[source,java]
+------------------------------------------------------
+public interface Pages
 {
-    @View(name = "home", extension = JSP)
-    class Index implements ViewConfig { }
+    @View(name = "home", extension = JSP)
+    class Index implements ViewConfig { }
 
-    @View(navigation = REDIRECT, viewParams = INCLUDE)
-    interface Admin extends ViewConfig
+    @View(navigation = REDIRECT, viewParams = INCLUDE)
+    interface Admin extends ViewConfig
     {
-        interface Statistics
+        interface Statistics
         {
-            @View //optional
-            class Index implements ViewConfig { }
+            @View //optional
+            class Index implements ViewConfig { }
 
-            class Home implements Admin { }
+            class Home implements Admin { }
         }
 
-        class Index implements Admin { }
+        class Index implements Admin { }
 
-        @View(navigation = FORWARD)
-        class Home implements Admin { }
+        @View(navigation = FORWARD)
+        class Home implements Admin { }
     }
-}
-
-
-
-

In this case Pages.Admin.Statistics is just an interface to reflect +} +------------------------------------------------------ + +In this case `Pages.Admin.Statistics` is just an interface to reflect the folder structure. For sure it is also possible that it extends an existing view-config interface and other folders and/or pages inherit -its meta-data (like Pages.Admin).

-
-
-

Furthermore, inheritance can be used to ensure navigation to the correct +its meta-data (like `Pages.Admin`). + +Furthermore, inheritance can be used to ensure navigation to the correct area in the application. In the following example the return type of the action-method (and therefore the compiler of Java) ensures that the -navigation target of this method is within the admin-area.

-
-
-
-
public Class<? extends Pages.Admin> toNextPage()
+navigation target of this method is within the admin-area.
+
+[source,java]
+------------------------------------------------
+public Class<? extends Pages.Admin> toNextPage()
 {
-    return Pages.Admin.Index.class;
-}
-
-
-
-

File (@View) and Folder (@Folder) Paths

-
-

@View as well as @Folder are optional annotations. @Folder is only + return Pages.Admin.Index.class; +} +------------------------------------------------ + +==== File (@View) and Folder (@Folder) Paths + +`@View` as well as `@Folder` are optional annotations. `@Folder` is only needed for using a different folder-name or for marking folder configs if they do not inherit from -org.apache.deltaspike.core.api.config.view.ViewConfig nor have a +`org.apache.deltaspike.core.api.config.view.ViewConfig` *nor* have a view-config for a page nested into them (like Pages.Wizard1.Step1). If it is not used explicitly, it gets added automatically (so you can query the meta-data at runtime even in cases you haveis not placed the -annotations explicitly). @View allows to customize a bit more and it +annotations explicitly). `@View` allows to customize a bit more and it also gets added automatically if it is not used explicitly. Whereas -@Folder gets added to all nested interfaces (above a view-config class -- like Pages and Pages.Wizard1), @View only gets added to classes +`@Folder` gets added to all nested interfaces (above a view-config class +- like Pages and Pages.Wizard1), `@View` only gets added to classes which in-/directly inherit from -org.apache.deltaspike.core.api.config.view.ViewConfig (like -Pages.Wizard1.Step1).

-
-
-

That means at runtime the following two configs lead to the same.

-
-
-
-
public interface Pages
+`org.apache.deltaspike.core.api.config.view.ViewConfig` (like
+Pages.Wizard1.Step1).
+
+That means at runtime the following two configs lead to the same.
+
+[source,java]
+---------------------------------------------
+public interface Pages
 {
-    interface Wizard1
+    interface Wizard1
     {
-        class Step1 implements ViewConfig { }
+        class Step1 implements ViewConfig { }
     }
 }
 
-//leads to the same as
+//leads to the same as
 
-@Folder
-public interface Pages
+@Folder
+public interface Pages
 {
-    @Folder
-    interface Wizard1
+    @Folder
+    interface Wizard1
     {
-        @View
-        class Step1 implements ViewConfig { }
+        @View
+        class Step1 implements ViewConfig { }
     }
-}
-
-
-
-

The example above leads to the following paths:

-
-
-
    -
  • -

    /pages/

    -
  • -
  • -

    /pages/wizard1

    -
  • -
  • -

    /pages/wizard1/step1.xhtml

    -
  • -
-
-
-

To customize it you can use @Folder#name, @View#basePath, -@View#name and @View#extension (or you register custom -`NameBuilder`s inline or globally).

-
-
-
@Folder#name
-
-

The rules are pretty simple. You will get what you write. There are only -two additional features:

-
-
-
    -
  • -

    You do not have to care about duplicated '/' (e.g. /folder1//folder2/step1.xhtml would get corrected auto. to /folder1/folder2/step1.xhtml)

    -
  • -
  • -

    With "." at the beginning (e.g. "./") you can keep the path before.

    -
  • -
-
-
-

The following example

-
-
-
-
interface Pages
+}
+---------------------------------------------
+
+The example above leads to the following paths:
+
+* /pages/
+* /pages/wizard1
+* /pages/wizard1/step1.xhtml
+
+To customize it you can use `@Folder#name`, `@View#basePath`,
+`@View#name` and `@View#extension` (or you register custom
+`NameBuilder`s inline or globally).
+
+===== @Folder#name
+
+The rules are pretty simple. You will get what you write. There are only
+two additional features:
+
+* You do not have to care about duplicated '/' (e.g. /folder1//folder2/step1.xhtml would get corrected auto. to /folder1/folder2/step1.xhtml)
+* With "." at the beginning (e.g. "./") you can keep the path before.
+
+The following example
+
+[source,java]
+---------------------------------------------------------------------------------
+interface Pages
 {
-    @Folder(name = "/w1/")
-    interface Wizard1
+    @Folder(name = "/w1/")
+    interface Wizard1
     {
-        class Step1 implements ViewConfig { }
+        class Step1 implements ViewConfig { }
     }
 
-    @Folder(name = "./w2/")
-    interface Wizard2 extends ViewConfig
+    @Folder(name = "./w2/")
+    interface Wizard2 extends ViewConfig
     {
-        class Step1 implements Wizard2 { }   //ViewConfig is inherited indirectly
+        class Step1 implements Wizard2 { }   //ViewConfig is inherited indirectly
     }
-}
-
-
-
-

leads to the following paths:

-
-
-
    -
  • -

    /pages/

    -
  • -
  • -

    /w1/

    -
  • -
  • -

    /w1/step1.xhtml

    -
  • -
  • -

    /pages/w2/step1.xhtml

    -
  • -
-
-
-
-
@View
-
-

The same naming rules apply to @View#basePath. However, it is only -valid to be used at view-config nodes which represent pages (→ classes -and not interfaces). On interfaces always use @Folder -(@View#basePath will get ignored there).

-
-
-
-
interface Pages
+}
+---------------------------------------------------------------------------------
+
+leads to the following paths:
+
+* /pages/
+* /w1/
+* /w1/step1.xhtml
+* /pages/w2/step1.xhtml
+
+===== @View
+
+The same naming rules apply to `@View#basePath`. However, it is only
+valid to be used at view-config nodes which represent pages (-> classes
+and not interfaces). On interfaces always use `@Folder`
+(`@View#basePath` will get ignored there).
+
+[source,java]
+---------------------------------------------
+interface Pages
 {
-    interface Wizard1
+    interface Wizard1
     {
-        @View //optional
-        class Step1 implements ViewConfig { }
+        @View //optional
+        class Step1 implements ViewConfig { }
 
-        @View(basePath = "/")
-        class Step2 implements ViewConfig { }
+        @View(basePath = "/")
+        class Step2 implements ViewConfig { }
 
-        @View(basePath = "./") //or just "."
-        class Step3 implements ViewConfig { }
+        @View(basePath = "./") //or just "."
+        class Step3 implements ViewConfig { }
 
-        @View(basePath = "/w1/")
-        class Step4 implements ViewConfig { }
+        @View(basePath = "/w1/")
+        class Step4 implements ViewConfig { }
 
-        @View(basePath = "./w1/")
-        class Step5 implements ViewConfig { }
+        @View(basePath = "./w1/")
+        class Step5 implements ViewConfig { }
     }
-}
-
-
-
-

leads to the following paths:

-
-
-
    -
  • -

    /pages

    -
  • -
  • -

    /pages/wizard1/

    -
  • -
  • -

    /pages/wizard1/step1.xhtml

    -
  • -
  • -

    /step2.xhtml

    -
  • -
  • -

    /pages/wizard1/step3.xhtml

    -
  • -
  • -

    /w1/step4.xhtml

    -
  • -
  • -

    /pages/wizard/w1/step5.xhtml

    -
  • -
-
-
-

and depending on additional meta-data you would like to inherit (e.g. -@View(navigation = REDIRECT)), you can also use:

-
-
-
-
@View(navigation = REDIRECT)
-interface Pages extends ViewConfig
+}
+---------------------------------------------
+
+leads to the following paths:
+
+* /pages
+* /pages/wizard1/
+* /pages/wizard1/step1.xhtml
+* /step2.xhtml
+* /pages/wizard1/step3.xhtml
+* /w1/step4.xhtml
+* /pages/wizard/w1/step5.xhtml
+
+and depending on additional meta-data you would like to inherit (e.g.
+`@View(navigation = REDIRECT)`), you can also use:
+
+[source,java]
+------------------------------------------
+@View(navigation = REDIRECT)
+interface Pages extends ViewConfig
 {
-    interface Wizard1 extends Pages
+    interface Wizard1 extends Pages
     {
-        @View
-        class Step1 implements Wizard1 { }
+        @View
+        class Step1 implements Wizard1 { }
 
-        @View(basePath = "/")
-        class Step2 implements Wizard1 { }
+        @View(basePath = "/")
+        class Step2 implements Wizard1 { }
 
-        @View(basePath = "./")
-        class Step3 implements Wizard1 { }
+        @View(basePath = "./")
+        class Step3 implements Wizard1 { }
 
-        @View(basePath = "/w1/")
-        class Step4 implements Wizard1 { }
+        @View(basePath = "/w1/")
+        class Step4 implements Wizard1 { }
 
-        @View(basePath = "./w1/")
-        class Step5 implements Wizard1 { }
+        @View(basePath = "./w1/")
+        class Step5 implements Wizard1 { }
     }
-}
-
-
-
-

It leads to the same paths, but in addition @View#navigation gets -inherited along the inheritance path.

-
-
-
-
-

Navigation Parameters

-
-

Since the view-config is static, an approach to add parameters is +} +------------------------------------------ + +It leads to the same paths, but in addition `@View#navigation` gets +inherited along the inheritance path. + +==== Navigation Parameters + +Since the view-config is static, an approach to add parameters is needed. The following part shows different possibilities to add parameters which end up in the final URL after '?' (in case of the integration with JSF). It is not needed to add all (types of) parameters that way. Some get added automatically based on special meta-data (e.g. -@View#navigation and @View#viewParams). Instead of adding -"faces-redirect=true" manually it is done for you as soon as you are -using @View(navigation = REDIRECT). The same goes for -"includeViewParams=true" and @View(viewParams = INCLUDE).

-
-
-
-

Static Configuration via @NavigationParameter

-
-

In some cases, it is needed to add an information in any case. So you can -annotate the view-config class with @NavigationParameter. Supported -values are static strings or EL-expressions.

-
-
-
-
public interface Pages extends ViewConfig
-{
-    @NavigationParameter(key = "param1", value = "staticValue1")
-    class Index implements Pages { }
-
-    @NavigationParameter.List({
-        @NavigationParameter(key = "param1", value = "staticValue1"),
-        @NavigationParameter(key = "param2", value = "#{myBean.property1}")
+`@View#navigation` and `@View#viewParams`). Instead of adding
+`"faces-redirect=true"` manually it is done for you as soon as you are
+using `@View(navigation = REDIRECT)`. The same goes for
+`"includeViewParams=true"` and `@View(viewParams = INCLUDE)`.
+
+==== Static Configuration via @NavigationParameter
+
+In some cases, it is needed to add an information in any case. So you can
+annotate the view-config class with `@NavigationParameter`. Supported
+values are static strings or EL-expressions.
+
+[source,java]
+---------------------------------------------------------------------------
+public interface Pages extends ViewConfig
+{
+    @NavigationParameter(key = "param1", value = "staticValue1")
+    class Index implements Pages { }
+
+    @NavigationParameter.List({
+        @NavigationParameter(key = "param1", value = "staticValue1"),
+        @NavigationParameter(key = "param2", value = "#{myBean.property1}")
     })
-    class Overview implements Pages { }
-}
-
-
-
-

Instead of using parameters in any case, it is also possible to configure -them statically for particular methods:

-
-
-
-
@Model
-public class PageBean
+    class Overview implements Pages { }
+}
+---------------------------------------------------------------------------
+
+Instead of using parameters in any case, it is also possible to configure
+them statically for particular methods:
+
+[source,java]
+-----------------------------------------------------------------------
+@Model
+public class PageBean
 {
-    @NavigationParameter(key = "param2", value = "#{myBean.property1}")
-    public Class<? extends ViewConfig> actionMethod1()
+    @NavigationParameter(key = "param2", value = "#{myBean.property1}")
+    public Class<? extends ViewConfig> actionMethod1()
     {
-        return SimplePageConfig.class;
+        return SimplePageConfig.class;
     }
 
-    @NavigationParameter.List({
-        @NavigationParameter(key = "param1", value = "staticValue1"),
-        @NavigationParameter(key = "param2", value = "staticValue2")
+    @NavigationParameter.List({
+        @NavigationParameter(key = "param1", value = "staticValue1"),
+        @NavigationParameter(key = "param2", value = "staticValue2")
     })
-    public Class<? extends ViewConfig> actionMethod2()
+    public Class<? extends ViewConfig> actionMethod2()
     {
-        return SimplePageConfig.class;
+        return SimplePageConfig.class;
     }
-}
-
-
-
-
Dynamic Configuration via NavigationParameterContext
-
-

Instead of using parameters in a static fashion (as shown above), it is +} +----------------------------------------------------------------------- + +===== Dynamic Configuration via NavigationParameterContext + +Instead of using parameters in a static fashion (as shown above), it is also possible to add them dynamically (e.g. in case of special -conditions).

-
-
-
-
@Named
-@SessionScoped
-public class PageBean
+conditions).
+
+[source,java]
+--------------------------------------------------------------------------------------
+@Named
+@SessionScoped
+public class PageBean
 {
-    private int currentValue = -10;
+    private int currentValue = -10;
 
-    @Inject
-    private NavigationParameterContext navigationParameterContext;
+    @Inject
+    private NavigationParameterContext navigationParameterContext;
 
-    public Class<? extends ViewConfig> actionMethod()
+    public Class<? extends ViewConfig> actionMethod()
     {
         currentValue++;
 
-        if (currentValue >= 0)
+        if (currentValue >= 0)
         {
-            this.navigationParameterContext.addPageParameter("cv", this.currentValue);
+            this.navigationParameterContext.addPageParameter("cv", this.currentValue);
         }
-        return SimplePageConfig.class;
+        return SimplePageConfig.class;
     }
-}
-
-
-
-
-
-

Security Integration via @Secured

-
-

This annotation is a custom view-meta-data provided by the +} +-------------------------------------------------------------------------------------- + +==== Security Integration via @Secured + +This annotation is a custom view-meta-data provided by the Security-module which allows to integrate third-party frameworks (or custom approaches) to secure pages as well as whole folders. You can annotate specific parts or a marker-interface. -CustomAccessDecisionVoter used in the following example can be any +`CustomAccessDecisionVoter` used in the following example can be any implementation of -org.apache.deltaspike.security.api.authorization.AccessDecisionVoter +`org.apache.deltaspike.security.api.authorization.AccessDecisionVoter` and needs to be a standard CDI bean which means you can use dependecy-injection to trigger any kind of security check. All parts -which inherit from SecuredPages (Pages.Admin, Pages.Admin.Index -and Pages.Admin.Home) are protected by CustomAccessDecisionVoter.

-
-
-

(It is easy to check this hierarchy in a modern Java-IDE. Only for +which inherit from `SecuredPages` (`Pages.Admin`, `Pages.Admin.Index` +and `Pages.Admin.Home`) are protected by `CustomAccessDecisionVoter`. + +(It is easy to check this hierarchy in a modern Java-IDE. Only for displaying the final meta-data for every node in the IDE a special -plug-in would be needed.)

-
-
-
-
@Secured(CustomAccessDecisionVoter.class)
-public interface SecuredPages {}
+plug-in would be needed.)
+
+[source,java]
+-----------------------------------------------
+@Secured(CustomAccessDecisionVoter.class)
+public interface SecuredPages {}
 
-@View(navigation = REDIRECT)
-public interface Pages extends ViewConfig
+@View(navigation = REDIRECT)
+public interface Pages extends ViewConfig
 {
-    class Index implements Pages { }
+    class Index implements Pages { }
 
-    interface Admin extends Pages, SecuredPages
+    interface Admin extends Pages, SecuredPages
     {
-        class Index implements Admin { }
+        class Index implements Admin { }
 
-        @View(navigation = FORWARD)
-        class Home implements Admin { }
+        @View(navigation = FORWARD)
+        class Home implements Admin { }
     }
-}
-
-
-
-

For sure it is also possible to use it without a special interface. In -this case you would need:

-
-
-
-
@View(navigation = REDIRECT)
-public interface Pages extends ViewConfig
+}
+-----------------------------------------------
+
+For sure it is also possible to use it without a special interface. In
+this case you would need:
+
+[source,java]
+---------------------------------------------
+@View(navigation = REDIRECT)
+public interface Pages extends ViewConfig
 {
-    class Index implements Pages { }
+    class Index implements Pages { }
 
-    @Secured(CustomAccessDecisionVoter.class)
-    interface Admin extends Pages
+    @Secured(CustomAccessDecisionVoter.class)
+    interface Admin extends Pages
     {
-        class Index implements Admin { }
+        class Index implements Admin { }
 
-        @View(navigation = FORWARD)
-        class Home implements Admin { }
+        @View(navigation = FORWARD)
+        class Home implements Admin { }
     }
-}
-
-
-
-

or:

-
-
-
-
@View(navigation = REDIRECT)
-public interface Pages extends ViewConfig
+}
+---------------------------------------------
+
+or:
+
+[source,java]
+-------------------------------------------------
+@View(navigation = REDIRECT)
+public interface Pages extends ViewConfig
 {
-    class Index implements Pages { }
+    class Index implements Pages { }
 
-    interface Admin extends Pages
+    interface Admin extends Pages
     {
-        @Secured(CustomAccessDecisionVoter.class)
-        class Index implements Admin { }
+        @Secured(CustomAccessDecisionVoter.class)
+        class Index implements Admin { }
 
-        @Secured(CustomAccessDecisionVoter.class)
-        @View(navigation = FORWARD)
-        class Home implements Admin { }
+        @Secured(CustomAccessDecisionVoter.class)
+        @View(navigation = FORWARD)
+        class Home implements Admin { }
     }
-}
-
-
-
-
-

View-Controller Callbacks via @ViewControllerRef

-
-

This annotation is a custom view-meta-data provided by the JSF-module +} +------------------------------------------------- + + +==== View-Controller Callbacks via @ViewControllerRef + +This annotation is a custom view-meta-data provided by the JSF-module which allows to configure beans which should act as view-controllers. -That means they can use view-controller callbacks like @InitView, -@PreViewAction, @PreRenderView and @PostRenderView. The following -example shows the usage of @PreRenderView.

-
-
-
-
//@View //optional
-@ViewControllerRef(MyPageController.class)
-public class MyPage implements ViewConfig
+That means they can use view-controller callbacks like `@InitView`,
+`@PreViewAction`, `@PreRenderView` and `@PostRenderView`. The following
+example shows the usage of `@PreRenderView`.
+
+[source,java]
+------------------------------------------
+//@View //optional
+@ViewControllerRef(MyPageController.class)
+public class MyPage implements ViewConfig
 {
 }
 
-@Model
-public class MyPageController
+@Model
+public class MyPageController
 {
-    @PreRenderView
-    protected void load()
+    @PreRenderView
+    protected void load()
     {
-        //...
+        //...
     }
-}
-
-
-
-

From DeltaSpike 0.7, it is possible to observe exceptions thrown by a +} +------------------------------------------ + +From DeltaSpike 0.7, it is possible to observe exceptions thrown by a @PreRenderView callback and use your configured Default-Error-View to -display the exception.

-
-
-
Example
-
-
@ExceptionHandler
-public class ErrorViewAwareExceptionHandler {
-    @Inject
-    private ViewConfigResolver viewConfigResolver;
+display the exception.
+
+.Example
+[source,java]
+--------------------------------------------------------------------------------------------------------------
+@ExceptionHandler
+public class ErrorViewAwareExceptionHandler {
+    @Inject
+    private ViewConfigResolver viewConfigResolver;
 
-    public void onIllegalStateException(@Handles ExceptionEvent<IllegalStateException> e)
+    public void onIllegalStateException(@Handles ExceptionEvent<IllegalStateException> e)
     {
         FacesContext facesContext = FacesContext.getCurrentInstance();
 
-        String viewId = viewConfigResolver.getDefaultErrorViewConfigDescriptor().getViewId();
+        String viewId = viewConfigResolver.getDefaultErrorViewConfigDescriptor().getViewId();
         UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext, viewId);
         facesContext.setViewRoot(viewRoot);
-        //... - e.g.: store the exception in a page-bean for the default-error-view
+        //... - e.g.: store the exception in a page-bean for the default-error-view
     }
-}
-
-
-
-
-

Referencing Views via @ViewRef

-
-

With @ViewControllerRef#value you can annotate a view-config class to -bind (/reference) a controller to it. @ViewRef#config allows the same +} +-------------------------------------------------------------------------------------------------------------- + +==== Referencing Views via @ViewRef + +With `@ViewControllerRef#value` you can annotate a view-config class to +bind (/reference) a controller to it. `@ViewRef#config` allows the same in the other direction. Use an existing view-config to reference one or -many view/s.

-
-
-
Example
-
-
public interface Pages extends ViewConfig
+many view/s.
+
+.Example
+[source,java]
+----------------------------------------------------
+public interface Pages extends ViewConfig
 {
-    class Index implements Pages { }
+    class Index implements Pages { }
 }
 
-@ViewRef(Pages.Index.class)
-//...
-public class IndexController implements Serializable
+@ViewRef(Pages.Index.class)
+//...
+public class IndexController implements Serializable
 {
-    @PreRenderView
-    protected void preRenderView()
+    @PreRenderView
+    protected void preRenderView()
     {
-        //...
+        //...
     }
 
-    //...
-}
-
-
-
-

The above example leads to the invocation of the pre-render-view logic before + //... +} +---------------------------------------------------- + +The above example leads to the invocation of the pre-render-view logic before /pages/page1.xhtml gets rendered (and it will not be called for other -pages).

-
-
-
-

Using the (Optional) ViewNavigationHandler

-
-

With JSF you typically navigate with the action-method bound to a +pages). + +==== Using the (Optional) ViewNavigationHandler + +With JSF you typically navigate with the action-method bound to a command-component. However, also JSF supports manual navigation via -javax.faces.application.NavigationHandler. With -ViewNavigationHandler DeltaSpike provides an equivalent optimized for +`javax.faces.application.NavigationHandler`. With +`ViewNavigationHandler` DeltaSpike provides an equivalent optimized for type-safe view-configs which is easier to use (and can be used also for -other (supported) view technology).

-
-
-
Simple Example
-
-
public interface Pages {
-    class Index implements ViewConfig { }
+other (supported) view technology).
+
+.Simple Example
+[source,java]
+-----------------------------------------------------------------
+public interface Pages {
+    class Index implements ViewConfig { }
 }
 
-@Model
-public class AnyController
+@Model
+public class AnyController
 {
-    @Inject
-    private ViewNavigationHandler viewNavigationHandler;
+    @Inject
+    private ViewNavigationHandler viewNavigationHandler;
 
-    public void anyMethod()
+    public void anyMethod()
     {
-        //navigates to /pages/index.xhtml
-        this.viewNavigationHandler.navigateTo(Pages.Index.class);
+        //navigates to /pages/index.xhtml
+        this.viewNavigationHandler.navigateTo(Pages.Index.class);
     }
-}
-
-
-
-

Also in this case (optional) meta-data will be used for the navigation -process, since ViewNavigationHandler just delegates to the active -navigation-handler (of JSF).

-
-
-
-

Configuring a Default Error-View

-
-

It is possible to mark one view-config class as default error-view. That +} +----------------------------------------------------------------- + +Also in this case (optional) meta-data will be used for the navigation +process, since `ViewNavigationHandler` just delegates to the active +navigation-handler (of JSF). + +==== Configuring a Default Error-View + +It is possible to mark one view-config class as default error-view. That means in case of errors it will be used as navigation target automatically. Furthermore, it is also possible to use it in your code -instead of hardcoding your error-view across the whole application.

-
-
-

In case of

-
-
-
-
public interface Pages {
-    class Index implements ViewConfig { }
+instead of hardcoding your error-view across the whole application.
 
-    class CustomErrorPage extends DefaultErrorView { }
-}
-
-
-
-

it is possible to navigate with DefaultErrorView.class instead of -hardcoding it to Pages.CustomErrorPage.class.

-
-
-
-
@Model
-public class PageController
+In case of
+
+[source,java]
+------------------------------------------------------
+public interface Pages {
+    class Index implements ViewConfig { }
+
+    class CustomErrorPage extends DefaultErrorView { }
+}
+------------------------------------------------------
+
+it is possible to navigate with `DefaultErrorView.class` instead of
+hardcoding it to `Pages.CustomErrorPage.class`.
+
+[source,java]
+-------------------------------------------------------------------------
+@Model
+public class PageController
 {
-    public Class<? extends ViewConfig> actionWithoutError()
+    public Class<? extends ViewConfig> actionWithoutError()
     {
-        return Pages.Index.class;
+        return Pages.Index.class;
     }
 
-    public Class<? extends ViewConfig> actionWithError()
+    public Class<? extends ViewConfig> actionWithError()
     {
-        //navigates to the view which is configured as default error-view
-        return DefaultErrorView.class;
+        //navigates to the view which is configured as default error-view
+        return DefaultErrorView.class;
     }
-}
-
-
-
-

If you are outside of an action-method you can also use it in -combination with ViewNavigationHandler.

-
-
-
-
@Model
-public class AnyController
+}
+-------------------------------------------------------------------------
+
+If you are outside of an action-method you can also use it in
+combination with `ViewNavigationHandler`.
+
+[source,java]

[... 1763 lines stripped ...]