プライムフェイスのメッセージ、メッセージ、そしてグロープコンポーネントの例

メッセージは通知、情報提供、そしてユーザーが達成したアクションについての意識を高めるために通常使用されます。通常、情報、エラー、警告などを表示するためにメッセージが使用されます。PrimefacesはJSFの実装と同様に、この目的のために使用されるさまざまなタイプのコンポーネントを提供しています。メッセージ、メッセージおよびグロウルは、この目的のために使用される唯一のコンポーネントです。このチュートリアルでは、これらのコンポーネントをアプリケーションに組み込むための手助けをします。

プライムフェイスのメッセージの基本情報。

メッセージは、標準のJSFメッセージコンポーネントの事前にスキンが適用された拡張バージョンです。

Tag message
Component Class org.primefaces.component.message.Message
Component Type org.primefaces.component.Message
Component Family org.primefaces.component
Renderer Type org.primefaces.component.MessageRenderer
Renderer Class org.primefaces.component.message.MessageRenderer

プライムフェイスのメッセージ属性

Name Default Type Description
id null String Unique identifier of the component.
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean.
showSummary false Boolean Specifies if the summary of the FacesMessage should be displayed.
showDetail true Boolean Specifies if the detail of the FacesMessage should be displayed.
for null String Id of the component whose messages to display.
redisplay true Boolean Defines if already rendered messages should be displayed
display both String Defines the display mode.
escape true Boolean Defines whether html would be escaped or not.
severity null String Comma separated list of severities to display only.
style null String Inline style of the component.
styleClass null String Style class of the component.

Primefaces Messageの使い方をはじめよう

一般的に、アプリケーションにメッセージを追加するには、自分自身のFacesContextインスタンスにFacesMessageのインスタンスを追加する必要があります。その後、RenderResponseフェーズで表示されるようになります。これらのメッセージの多くは手動で追加され、同時に他のメッセージはJSFの実装によって追加されます。バリデーションや変換に関わる場合、実際には自分のコードの一部ではないような多くのメッセージが表示されます。次の例は、必須の入力を記入せずにフォームを送信した際に表示されるエラーメッセージを生成する簡単なバリデーションのプロセスの例です。index.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:outputPanel>
		<p:outputLabel value="Typing of your message is mandatory:"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}" required="true"/>
	<p:message id="message" for="input"></p:message>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action" action="#{messageManagedBean.doSomeAction}" update="input message"></p:commandButton>
</h:form>
</html>

メッセージ管理Bean.java

package com.scdev;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class MessageManagedBean {
	private String message;

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String doSomeAction(){
		return "";
	}
}

上記のコードの詳しい説明を以下に示します。

  • The rendered message isn’t part of your code, it’s queued by the jsf implementation through executing of ProcessValidation phase.
  • RenderResponse phase is responsible of getting messages displayed.
  • Queuing messages require to pass through jsf lifecycle. Normal starting of jsf lifecycle get done by activating an action.
  • To ensure that certain input is required, required attribute must be set to true. ProcessValidation will look at your required components and queuing messages in case some of them are missed up.
  • Message component used mainly for associating specific component with a message. Typically, this message will always be used for displaying all messages for accompanying component.
  • The association between the message and it’s relevant component get achieved by providing for attribute.

Primefacesのメッセージ表示モード

メッセージコンポーネントには、3つの異なる表示モードがあります。

  • text: Only message text is displayed.
  • icon: Only message severity is displayed and message text is visible as a tooltip.
  • both (default): Both icon and text are displayed.

前に紹介した同じ例を変更して、使用するディスプレイモードを制御しましょう。index.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:outputPanel>
		<p:outputLabel value="Typing of your message is mandatory:"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}" required="true"/>
	<p:message id="message" for="input" display="icon"></p:message>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action" action="#{messageManagedBean.doSomeAction}" update="input message"></p:commandButton>
</h:form>
</html>

プライムフェイセスのメッセージ基本情報

メッセージは、標準的なJSFメッセージコンポーネントの拡張バージョンであるプリスキンされたバージョンです。

Tag messages
Component Class org.primefaces.component.messages.Messages
Component Type org.primefaces.component.Messages
Component Family org.primefaces.component
Renderer Type org.primefaces.component.MessagesRenderer
Renderer Class org.primefaces.component.messages.MessagesRenderer

プライムフェイスのメッセージの属性

Name Default Type Description
id null String Unique identifier of the component.
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean.
showSummary true Boolean Specifies if the summary of the FacesMessages should be displayed.
showDetail false Boolean Specifies if the detail of the FacesMessages should be displayed.
globalOnly false String When true, only facesmessages with no clientIds are displayed.
redisplay true Boolean Defines if already rendered messages should be displayed
autoUpdate false Boolean Enables auto update mode if set true.
for null String Name of associated key, takes precedence when used with globalOnly.
escape true Boolean Defines whether html would be escaped or not.
severity null String Comma separated list of severities to display only.
closable false Boolean Adds a close icon to hide the messages.
style null String Inline style of the component.
styleClass null String Style class of the component.
showIcon true Boolean Defines if severity icons would be displayed.

Primefaces Messagesの使い方を始める

「p:messages」を使用する際には、ページ内の特定のコントロールに属していない一般的なメッセージを表示するために使用されることを知っておくことが重要です。以下のサンプルは、一般的なメッセージを表示するために「p:messages」をどのように使用するかを示しています。index2.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:messages id="messages"/>
	<p:outputPanel>
		<p:outputLabel value="Typing of your preferred technical site"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}"/>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action"
			action="#{messageManagedBean.doSomeAction}" update="messages"></p:commandButton>
</h:form>
</html>

メッセージManagedBean.java

package com.scdev;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class MessageManagedBean {
	private String message ="";

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String doSomeAction(){
		if(this.message.equals("")){
			FacesContext.getCurrentInstance().addMessage(null,
					new FacesMessage(FacesMessage.SEVERITY_ERROR, "Empty value isn't accepted","Empty value isn't accepted"));
		}
		else if(this.message.equals("") == false){
			FacesContext.getCurrentInstance().addMessage(null,
					new FacesMessage(FacesMessage.SEVERITY_ERROR, "You entered value","You entered value"));
		}
		return "";
	}
}

以下に、これまでの出来事の詳細な説明があります。

  • Messages component used mainly for general message coverage.
  • You can add a message by creating an instance of FacesMessage that’s comprised from message’s severity, message detail section and message summary section. After finish the creation of message, it’s required for displaying adding it into your FacesContext. RenderResponse will display it into your page.

深刻度レベル

前に探索した例では、ページに表示されるエラーの重大度が付いた2つのメッセージを提供しました。p:messagesコンポーネントが表示するメッセージのタイプを制御できることを知ることが重要です。カンマ区切りでinfo、warn、error、fatalの値を指定することで、表示されるメッセージを制御できます。index3.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:messages id="messages" severity="fatal,info,warn"/>
	<p:outputPanel>
		<p:outputLabel value="Typing of your preferred technical site"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}"/>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action" 
			action="#{messageManagedBean.doSomeAction}" update="messages"></p:commandButton>
</h:form>
</html>

メッセージManagedBean.java

package com.scdev;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class MessageManagedBean {
	private String message ="";

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	public String doSomeAction(){
		if(this.message.equals("")){
			FacesContext.getCurrentInstance().addMessage(null, 
					new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error Message","Error Message"));
			FacesContext.getCurrentInstance().addMessage(null, 
					new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal Message","Fatal Message"));
			FacesContext.getCurrentInstance().addMessage(null, 
					new FacesMessage(FacesMessage.SEVERITY_WARN, "WARN Message","WARN Message"));
			FacesContext.getCurrentInstance().addMessage(null, 
					new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO Message","INFO Message"));			
		}		
		return "";
	}
}

自動更新

もし以前に提供されたすべての例を調査しているのであれば、p:commandButtonがメッセージコンポーネントを非同期で更新していることに気づくはずです。そのような配置を避けることができます、特に階層構造のあるページにおいては。アプリケーションがスローしたすべての一般的なメッセージを表示するために使用されるメッセージコンポーネントを含むテンプレートページがあると仮定しましょう。index4.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:messages id="messages" autoUpdate="true"/>
	<p:outputPanel>
		<p:outputLabel value="Typing of your preferred technical site"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}"/>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action" 
			action="#{messageManagedBean.doSomeAction}"></p:commandButton>
</h:form>
</html>

メッセージ管理ビーン.java

package com.scdev;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class MessageManagedBean {
	private String message ="";

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	public String doSomeAction(){
		if(this.message.equals("")){
			FacesContext.getCurrentInstance().addMessage(null, 
					new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error Message","Error Message"));		
		}		
		return "";
	}
}
  • Developed command action hasn’t provided update attribute. Even though update attribute isn’t there, yet the message has been displayed cause the autoUpdate is used by the messages component itself.

ターゲットとなるメッセージ

メッセージを表示するために、特定のメッセージコンポーネントを使用して表示を制御することができます。メッセージコンポーネントAとB、および入力コンポーネント1と2を使用しましょう。入力番号1の場合、メッセージはメッセージコンポーネントAに対して表示され、2の場合はメッセージコンポーネントBが使用されます。以下の例では、そのような使用方法の影響を示しています。index5.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:messages for="input1" id="messagesA"/>
	<p:messages for="input2" id="messagesB"/>
	<p:outputPanel>
		<p:outputLabel value="Typing of your preferred technical site"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input1" value="#{messageManagedBean.message}"/>
	<h:inputText id="input2" value="#{messageManagedBean.message}"/>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action One" 
			action="#{messageManagedBean.doSomeActionOne}" update="messagesA messagesB"></p:commandButton>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action Two" 
			action="#{messageManagedBean.doSomeActionTwo}" update="messagesA messagesB"></p:commandButton>			
</h:form>
</html>

メッセージ管理ビーン.java

package com.scdev;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class MessageManagedBean {
	private String message ="";

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	public String doSomeActionOne(){
		if(this.message.equals("")){
			FacesContext.getCurrentInstance().addMessage("form:input1", 
					new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error Message For Input1","Error Message For Input1"));		
		}		
		return "";
	}
	public String doSomeActionTwo(){
		if(this.message.equals("")){
			FacesContext.getCurrentInstance().addMessage("form:input2", 
					new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error Message For Input2","Error Message For Input2"));		
		}		
		return "";
	}	
}

以下を日本語で自然な言葉に言い換えてください。1つのオプションで結構です:

“Can you please explain the directions again?”
「もう一度、道案内を説明していただけますか?」

  • Featuring Target Messages requires associate your messages component with a component using for attribute and providing clientId for all of those messages that are added into FacesContext.

jsfの実装では、コンポーネントに一意の識別子が割り当てられています。この識別子はFormId:componentIdという形式を取ります。formコンポーネントに対してprependIdをfalseに設定することで、この識別を無効化することができます。そのため、すべてのコンポーネントは実際にはcomponentIdのみを使用して識別され、識別されていないコンポーネントにはj_id4のようなランダムな識別子が使用されます。

プライムフェイセスのグロウル基本情報

Growlは、MacのGrowl通知ウィジェットをベースにしており、オーバーレイでFacesMessageを表示するために使用されます。また、メッセージコンポーネントやメッセージコンポーネントと同様です。

Tag Growl
Component Class org.primefaces.component.growl.Growl
Component Type org.primefaces.component.Growl
Component Family org.primefaces.component
Renderer Type org.primefaces.component.GrowlRenderer
Renderer Class org.primefaces.component.growl.GrowlRenderer

PrimefacesのGrowl属性

Name Default Type Description
id null String Unique identifier of the component
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean
sticky false Boolean Specifies if the message should stay instead of hidden automatically.
showSummary true Boolean Specifies if the summary of message should be displayed.
showDetail false Boolean Specifies if the detail of message should be displayed.
globalOnly false Boolean When true, only facesmessages without clientids are displayed.
life 6000 Integer Duration in milliseconds to display non-sticky messages.
autoUpdate false Boolean Specifies auto update mode.
redisplay true Boolean Defines if already rendered messaged should be displayed.
for null String Name of associated key, takes precedence when used with globalOnly.
escape true Boolean Defines whether html would be escaped or not.
severity null String Comma separated list of severities to display only.

PrimeFacesのGrowlを使い始める方法

Growlのコンポーネントは、これまでに議論されたメッセージの要素とはほとんど変わりませんので、ターゲット可能なメッセージや重要度レベルのオプションを提供するためにそれらを信頼することができます。以下の例は、Growlコンポーネントの最も単純な使用例を示しています。index6.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:growl id="message"/>
	<p:outputPanel>
		<p:outputLabel value="Typing of your preferred technical site"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}"/>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action One" 
			action="#{messageManagedBean.doSomeAction}" update="message"></p:commandButton>	
</h:form>
</html>

メッセージManagedBean.java

package com.scdev;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class MessageManagedBean {
	private String message ="";

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	public String doSomeAction(){
		if(this.message.equals("")){
			FacesContext.getCurrentInstance().addMessage(null, 
					new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error Message Displayed Growl","Error Message Displayed Growl"));		
		}		
		return "";
	}
}

プライムフェイス・メッセージの寿命

メッセージはそれぞれ6000ミリ秒表示された後に非表示になりますが、Growlのメッセージをスティッキーに制御できます。これは自動的に非表示にされないという意味です。index7.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:growl id="message" sticky="true"/>
	<p:outputPanel>
		<p:outputLabel value="Typing of your preferred technical site"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}"/>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action One" 
			action="#{messageManagedBean.doSomeAction}" update="message"></p:commandButton>	
</h:form>
</html>

あなたがGrowlメッセージを効果的に表示させたいならば、life属性の調整によりメッセージの表示時間を制御することもできます。index8.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:growl id="message" life="2000"/>
	<p:outputPanel>
		<p:outputLabel value="Typing of your preferred technical site"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}"/>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action One" 
			action="#{messageManagedBean.doSomeAction}" update="message"></p:commandButton>	
</h:form>
</html>

プライムフェイスのグローメッセージの配置

Growlメッセージが表示される位置も制御できます。デフォルトでは、Growlは右上隅に配置されていますが、CSSセレクタであるui-growlを使用して位置を制御することができます。 index9.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
	<style>
		.ui-growl {
			left:700px;
		}
	</style>
</h:head>
<h:form id="form">
	<p:growl id="message"/>
	<p:outputPanel>
		<p:outputLabel value="Typing of your preferred technical site"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}"/>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action One" 
			action="#{messageManagedBean.doSomeAction}" update="message"></p:commandButton>	
</h:form>
</html>

逃げる

すべてのPrimefacesメッセージコンポーネント(message、messages、growl)の場合、デフォルトではすべてのHTMLコンテンツがエスケープされて表示されます。PrimefacesメッセージコンポーネントでHTMLを表示する必要がある場合は、escapeをfalseに設定してください。 index10.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:messages id="message" escape="false"/>
	<p:outputPanel>
		<p:outputLabel value="Typing of your preferred technical site"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}"/>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action One" 
			action="#{messageManagedBean.doSomeAction}" update="message"></p:commandButton>	
</h:form>
</html>

メッセージManagedBean.java

package com.scdev;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class MessageManagedBean {
	private String message ="";

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	public String doSomeAction(){
		if(this.message.equals("")){
			FacesContext.getCurrentInstance().addMessage(null, 
					new FacesMessage(FacesMessage.SEVERITY_ERROR, "<i>Error Message Displayed</i>","<i>Error Message Displayed</i>"));		
		}		
		return "";
	}
}

詳細&要約メッセージの部分

メッセージの一部を表示することができるように制御することができますので、表示するメッセージの一部を選択することができます。すべてのFacesMessageには、メッセージがFacesContextに追加された後に提供されるサマリー部分と詳細部分が含まれています。すべてのPrimefacesのメッセージコンポーネントは、デフォルトでサマリー部分を表示します。FacesMessageの両方の部分を表示するために、showSummaryとshowDetailを指定することができます。index11.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:messages id="message" showDetail="true" showSummary="true" escape="false"/>
	<p:outputPanel>
		<p:outputLabel value="Typing of your preferred technical site"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}"/>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action One" 
			action="#{messageManagedBean.doSomeAction}" update="message"></p:commandButton>	
</h:form>
</html>

プライムフェイセスのメッセージグロウルのサマリー

様々なアプリケーション内で頻繁に使用されるメッセージは、Primefacesが提供するコンポーネントを利用して、情報提供、通知、情報を表示するために使用できます。コメント欄でご意見をお寄せいただき、ソースコードを見つけてください。

プライムフェイセスのメッセージプロジェクトをダウンロードしてください。

コメントを残す 0

Your email address will not be published. Required fields are marked *