最近の更新

2013年2月14日木曜日

(RichFaces4 ShowCase)EditorCustom

【目的】
RichFaces4 ShowCaseのEditorのツールバーをカスタマイズします。



【手順】
1.「RichFaces4プロジェクトの作成方法」の手順で、「RichFaces4Sample044-EditorCustom」といプロジェクトを作成。
※プロジェクトの設定は以下の通り。

動的
Web
プロジェクト
プロジェクト名RichFaces4Sample044-EditorCustom

ターゲット・ランタイムApache Tomcat v6.0
動的 web モジュール バージョン2.5
構成Apache Tomcat v6.0 デフォルト構成
EARメンバーシップチェックなし
ワーキング・セットチェックなし
Javaビルド・パス上のソース・フォルダーsrc
デフォルト出力フォルダーbuild\classes
Web
モジュール
コンテキスト・ルートRichFaces4Sample044-EditorCustom

コンテンツ・ディレクトリーWebContent
web.xml デプロイメント記述子の作成チェックあり


2.「WebContent/WEB-INF/web.xml」を以下の様に入力。
※Servlet APIが2.5の場合は以下の様にResource Servletの登録が必要。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">

    <display-name>RichFaces4Sample044-EditorCustom</display-name>

    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/org.richfaces.resources/*</url-pattern>
    </servlet-mapping>
</web-app>

3.「Ctrl+Shift+F」を押し、ソースコードをフォーマッティング、「Ctrl+S」でファイルを保存。
4.「任意のファイルの作成方法」の手順で、「WebContent/」ディレクトリに「index.xhtml」というファイルを作成。
5.「index.xhtml」を以下の様に入力。
<html xmlns="http://www.w3c.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
<h:head>
</h:head>
<h:body>
    <h:form>
        <rich:editor toolbar="custom1" height="100">
            <f:facet name="config">
                toolbar_custom1:
                [
                    { name: 'document', items : [ 'NewPage','Preview' ] },
                    { name: 'clipboard', items : [ 'Cut','Copy','Paste','-','Undo','Redo' ] },
                    { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','Scayt' ] },
                    { name: 'insert', items : [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe' ] },
                    '/',
                    { name: 'styles', items : [ 'Styles','Format' ] },
                    { name: 'basicstyles', items : [ 'Bold','Italic','Strike','-','RemoveFormat' ] },
                    { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote' ] },
                    { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
                    { name: 'tools', items : [ 'Maximize' ] }
                ]
            </f:facet>
        </rich:editor>
        <br />
        <rich:editor toolbar="custom2" height="100">
            <f:facet name="config">
                toolbar_custom2:
                [
                    { name: 'document', items : [ 'NewPage','Preview' ] }
                ]
            </f:facet>
        </rich:editor>
    </h:form>
</h:body>
</html>

6.「Ctrl+Shift+F」を押し、ソースコードをフォーマッティング、「Ctrl+S」でファイルを保存。
7.「動的Webアプリケーションをサーバーに配置する方法」の手順で、作成したプロジェクトをサーバーに配置します。
8.「サーバーをデバッグモードで起動する方法」の手順で、サーバーを起動します。
9.ブラウザで以下のURLにアクセスします。
http://localhost:8080/RichFaces4Sample044-EditorCustom/faces/index.xhtml

10.以下の様に表示されれば成功です。













































以上です。

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。

関連記事