sample_7.xhtml
3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:schedule="http://richfaces.org/sandbox/schedule">
<ui:composition template="/pages/template.xhtml">
    <ui:define name="body">
        <p>
            Schedule has support for internationalization.
            You need to provide messages in bundle registered with JSF
            as message-bundle (not resource-bundle!).
            List of available messages can be found in
        </p>
        <pre>
    org.richfaces.component.UIScheduleMessages_en.properties
        </pre>
        <p>
            As for now component is shipped with english and polish translation.
            This demo web app has additional myMessages_fr.properties with french translation
            to show how you can add custom translation.
            It should be packaged in WEB-INF/classes. (Maven apps can store it in src/main/resources)
            You also need to configure faces-config.xml like this:
        </p>
        <pre>
<application>
    <message-bundle>
        myMessages
    </message-bundle>
    <locale-config>
        <default-locale>en</default-locale>
        <supported-locale>pl</supported-locale>
        <supported-locale>fr</supported-locale>
        <supported-locale>en</supported-locale>
    </locale-config>
</application>
        </pre>
        <p>
            Note that if you want your component work in WebKit based browsers
            (i.e.:chrome,safari) you cannot use html entities in your
            messages. User numeric entities instead. i.e.: &#160; instead of &nbsp;
        </p>
        <p>
            Unfortunately, in JSF 2.0.2 the locale changes are visible on next request, so
            you must refresh screen or force two ajax requests.
        </p>
        <p>
            Unfortunately, dynamicly generated javascript resource is not automatically
            included by JSF, so if you want to use internationalization you must add this to your facelet:
        </p>
        <pre>
    <h:outputScript name="org.richfaces.renderkit.html.scripts.ScheduleMessages" target="head"/>
        </pre>
        <h:form>
            <h:selectOneListbox size="1" value="#{myBean.locale}">
                <f:selectItem itemValue="en" itemLabel="en"/>
                <f:selectItem itemValue="pl" itemLabel="pl"/>
                <f:selectItem itemValue="fr" itemLabel="fr"/>
                <a4j:support event="onchange" reRender="scheduleContainer"/>
            </h:selectOneListbox>
        </h:form>
        <h:panelGrid id="scheduleContainer">
            <ui:include src="schedule.xhtml">
                <ui:param name="mode" value="ajax"/>
            </ui:include>
        </h:panelGrid>
        <rich:insert src="/pages/sample_7.xhtml" highlight="xhtml"/>
    </ui:define>
</ui:composition>
</html>