PrimeFaces ShowCaseのRemoteCommandを実行します。
【手順】
1.「PrimeFacesプロジェクトの作成方法」の手順で、「PrimeFacesSample013-RemoteCommand」といプロジェクトを作成。
※プロジェクトの設定は以下の通り。
2.「WebContent/WEB-INF/web.xml」を以下の様に入力。
<?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>PrimeFacesSample013-RemoteCommand</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>
</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:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form>
<p:commandButton value="表示" type="button" onclick="display()" />
<p:outputPanel id="panel" layout="block">
<h:outputText value="あああいいいうううえええおおお。"
rendered="#{requestScope.shouldRender}" />
</p:outputPanel>
<p:remoteCommand name="display" update="panel">
<f:setPropertyActionListener value="#{true}"
target="#{requestScope.shouldRender}" />
</p:remoteCommand>
</h:form>
</h:body>
</html>
6.「Ctrl+Shift+F」を押し、ソースコードをフォーマッティング、「Ctrl+S」でファイルを保存。
7.「動的Webアプリケーションをサーバーに配置する方法」の手順で、作成したプロジェクトをサーバーに配置します。
8.「サーバーをデバッグモードで起動する方法」の手順で、サーバーを起動します。
9.ブラウザで以下のURLにアクセスします。
http://localhost:8080/PrimeFacesSample013-RemoteCommand/faces/index.xhtml
10.以下の様に表示されれば成功です。
RemoteCommand-01.png)
0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。