Changes for page Best Practices

Last modified by Vincent Massol on 2017/09/05

<
From version < 4.1 >
edited by Eduard Moraru
on 2012/05/23
To version < 5.1 >
edited by Eduard Moraru
on 2012/05/23
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -8,7 +8,7 @@
8 8  
9 9  Class sheet documents should be written using the following construct (this is an example for displaying documents containing XWiki.XWikiUsers objects):
10 10  
11 -{{code language='velocity'}}
11 +{{code language="velocity"}}
12 12  #set($obj = $doc.getObject("XWiki.XWikiUsers"))
13 13  #if(!$obj)
14 14   1 User Sheet
... ... @@ -19,7 +19,9 @@
19 19  #end
20 20  {{/code}}
21 21  
22 -{{info}}The 'if' tests first for the non existence. This is so that XWiki extract the title from the //1 User Sheet//, which is a proper title to display when viewsing the sheet page, instead of the computed name which will usually display something wrong.{{/info}}
22 +{{info}}
23 +The 'if' tests first for the non existence. This is so that XWiki extract the title from the //1 User Sheet//, which is a proper title to display when viewsing the sheet page, instead of the computed name which will usually display something wrong.
24 +{{/info}}
23 23  
24 24  = Handling errors when using xredirect for non-Javascript UIs =
25 25  
... ... @@ -31,7 +31,7 @@
31 31  
32 32  A simplified code for this in the background service that produces the error is:
33 33  
34 -{{code language='velocity'}}
36 +{{code language="velocity"}}
35 35  #handleRequest($success)
36 36  #if ($success)
37 37   #if ($request.action == 'get' || $request.xpage== 'plain')
... ... @@ -57,7 +57,7 @@
57 57  
58 58  For the background service, it translates to:
59 59  
60 -{{code language='velocity'}}
62 +{{code language="velocity"}}
61 61  ...
62 62   #elseif ("$!request.xredirect" != '')
63 63   ## No-JavaScript here. Redirect and forward error message.
... ... @@ -69,7 +69,7 @@
69 69  
70 70  On the UI side:
71 71  
72 -{{code language='velocity'}}
74 +{{code language="velocity"}}
73 73  ...
74 74   #set ($xredirect = $doc.getURL($context.action, $!{request.queryString}))
75 75   #set ($errorMessage = $request.session.getAttribute("${errorMessageKeyPrefix}${xredirect}"))
... ... @@ -82,7 +82,8 @@
82 82  {{/code}}
83 83  
84 84  Note that using xredirect's value as session key (prefixed or not) is a good idea because:
85 -1.it's already there in both the UI (for sending it as parameter) and the background service (received as parameter)
86 -2.it acts like a namespace, ensuring that the error will only be displayed for the current page/request.
87 87  
88 +1. it's already there in both the UI (for sending it as parameter) and the background service (received as parameter)
89 +1. it acts like a namespace, ensuring that the error will only be displayed for the current page/request.
90 +
88 88  This method works together with the whole purpose for which we are doing the redirect in the first place (so that the user can refresh the page without re-sending the action or re-posting a form), ensuring that after the first display, on a refresh, the error goes away.

Get Connected