웹사이트 검색

Primefaces 메시지, 메시지 & 으르렁거리는 구성 요소 예


메시지는 일반적으로 달성한 작업을 사용자에게 알리고 알리고 인식시키는 데 사용됩니다. 일반적으로 정보, 오류, 경고 등을 표시하는 데 사용되는 메시지입니다. 모든 jsf 구현과 마찬가지로 Primeface는 이를 수행하는 데 사용되는 다양한 유형의 구성 요소를 제공합니다. 메시지, 메시지 및 으르렁 거리는 소리는 이러한 목적으로 사용되는 유일한 구성 요소입니다. 이 가이드는 이러한 구성요소를 애플리케이션에 적용하는 데 도움이 됩니다.

Primefaces 메시지 기본 정보

메시지는 표준 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

Primefaces 메시지 속성

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 메시지 시작하기

일반적으로 애플리케이션에 메시지를 추가하려면 FacesMessage 인스턴스를 자체 FacesContext 인스턴스에 추가하여 이후 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>

MessageManagedBean.java

package com.journaldev;

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 "";
	}
}

  • 렌더링된 메시지는 코드의 일부가 아니며 ProcessValidation 단계 실행을 통해 jsf 구현에 의해 대기됩니다.
  • RenderResponse 단계는 메시지 표시를 담당합니다.
  • 대기 중인 메시지는 jsf 수명 주기를 통과해야 합니다. jsf 수명 주기의 정상적인 시작은 작업을 활성화하여 완료됩니다.
  • 특정 입력이 필요한지 확인하려면 필수 속성을 true로 설정해야 합니다. ProcessValidation은 필요한 구성 요소와 대기열 메시지 중 일부가 누락된 경우 이를 확인합니다.
  • 특정 구성 요소를 메시지와 연결하는 데 주로 사용되는 메시지 구성 요소. 일반적으로 이 메시지는 동반 구성 요소에 대한 모든 메시지를 표시하는 데 항상 사용됩니다.
  • 메시지와 관련 구성 요소 간의 연결은 속성을 제공하여 달성됩니다.

Primefaces 메시지 표시 모드

메시지 구성 요소에는 세 가지 표시 모드가 있습니다.

  • 텍스트: 메시지 텍스트만 표시됩니다.
  • 아이콘: 메시지 심각도만 표시되고 메시지 텍스트가 툴팁으로 표시됩니다.
  • both(기본값): 아이콘과 텍스트가 모두 표시됩니다.

사용될 디스플레이 모드를 제어하기 위해 이전에 소개된 동일한 예를 변경해 보겠습니다. <코드>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>

Primefaces 메시지 기본 정보

메시지는 표준 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

Primefaces 메시지 속성

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 메시지 시작하기

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>

MessageManagedBean.java

package com.journaldev;

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 "";
	}
}

  • 일반적인 메시지 범위에 주로 사용되는 메시지 구성 요소
  • 메시지의 심각도, 메시지 세부 정보 섹션 및 메시지 요약 섹션으로 구성된 FacesMessage 인스턴스를 생성하여 메시지를 추가할 수 있습니다. 메시지 생성을 완료한 후 FacesContext에 메시지를 추가하여 표시하는 데 필요합니다. RenderResponse가 페이지에 표시합니다.

심각도 수준

이전에 살펴본 예에서는 페이지 이후에 렌더링되는 오류 심각도가 있는 두 개의 메시지를 제공했습니다. p:messages 구성 요소가 표시할 이러한 메시지 유형을 제어할 수 있다는 것을 아는 것이 중요합니다. 쉼표로 구분된 정보, 경고, 오류, 치명적인 값으로 심각도 속성을 제공하면 표시되는 메시지를 제어할 수 있습니다. 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>

MessageManagedBean.java

package com.journaldev;

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>

MessageManagedBean.java

package com.journaldev;

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 "";
	}
}

  • 개발된 명령 작업이 업데이트 속성을 제공하지 않았습니다. 업데이트 속성이 없지만 메시지 구성 요소 자체에서 autoUpdate를 사용하기 때문에 메시지가 표시되었습니다.

타겟팅 가능한 메시지

메시지 표시는 특정 메시지 구성 요소를 사용하여 볼 수 있도록 제어할 수 있습니다. 두 개의 다른 메시지 구성 요소 {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>

MessageManagedBean.java

package com.journaldev;

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 "";
	}	
}

  • Target Messages를 표시하려면 FacesContext에 추가되는 모든 메시지에 대해 속성을 사용하고 clientId를 제공하는 구성 요소와 메시지 구성 요소를 연결해야 합니다.

jsf 구현은 해당 구성 요소에 고유 식별자를 할당했습니다. 이러한 식별자는 FormId:componentId 형식을 취합니다. 양식 구성 요소에 대해 prependId를 false로 제공하여 이 식별을 비활성화할 수 있습니다. 따라서 모든 구성 요소는 해당 componentId만 사용하여 실제로 식별되며 식별되지 않은 구성 요소는 j_id4와 같은 임의 식별을 사용하여 식별됩니다.

Primefaces Growl 기본 정보

Growl은 Mac의 Growl 알림 위젯을 기반으로 하며 메시지 및 메시지 구성 요소처럼 오버레이에 FacesMessages를 표시하는 데 사용됩니다.

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>

MessageManagedBean.java

package com.journaldev;

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 "";
	}
}

Primefaces 메시지 수명

각 메시지는 6000ms 동안 표시된 후 숨겨지므로 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>
<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은 오른쪽 상단 모서리에 위치하며 ui-growl이라는 CSS 선택기로 위치를 제어할 수 있습니다. 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 메시지 구성 요소(메시지, 메시지 및 으르렁거림)의 경우 기본적으로 모든 html 콘텐츠를 이스케이프 처리합니다. Primefaces 메시지 구성 요소를 통해 html을 표시해야 하는 경우 이스케이프를 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>

MessageManagedBean.java

package com.journaldev;

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 "";
	}
}

세부 정보 및 요약 메시지 부분

<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 메시지 Growl 요약

메시지는 게시되는 광범위한 애플리케이션 내에서 많이 사용됩니다. Primefaces는 애플리케이션 내에서 유익한 텍스트를 알리고 알리고 표시하는 데 사용할 수 있는 이러한 구성 요소를 대규모로 제공합니다. 아래에 댓글을 달아 우리에게 기여하고 소스 코드를 찾으십시오.

PrimeFaces 메시지 프로젝트 다운로드