本文整理匯總了Java中javax.faces.application.FacesMessage.setSeverity方法的典型用法代碼示例。如果您正苦於以下問題:Java FacesMessage.setSeverity方法的具體用法?Java FacesMessage.setSeverity怎麽用?Java FacesMessage.setSeverity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.application.FacesMessage
的用法示例。
在下文中一共展示了FacesMessage.setSeverity方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTrackById
import javax.faces.application.FacesMessage; //導入方法依賴的package包/類
public void onTrackById() {
Cargo cargo = cargoRepository.find(new TrackingId(trackingId));
if (cargo != null) {
List<HandlingEvent> handlingEvents = handlingEventRepository
.lookupHandlingHistoryOfCargo(new TrackingId(trackingId))
.getDistinctEventsByCompletionTime();
this.cargo = new CargoTrackingViewAdapter(cargo, handlingEvents);
} else {
// TODO See if this can be injected.
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage(
"Cargo with tracking ID: " + trackingId + " not found.");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
context.addMessage(null, message);
this.cargo = null;
}
}
示例2: register
import javax.faces.application.FacesMessage; //導入方法依賴的package包/類
public String register() {
String trackingId = null;
try {
if (!originUnlocode.equals(destinationUnlocode)) {
trackingId = bookingServiceFacade.bookNewCargo(
originUnlocode,
destinationUnlocode,
new SimpleDateFormat(FORMAT).parse(arrivalDeadline));
} else {
// TODO See if this can be injected.
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage(
"Origin and destination cannot be the same.");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
context.addMessage(null, message);
return null;
}
} catch (ParseException e) {
throw new RuntimeException("Error parsing date", e);
}
return "show.xhtml?faces-redirect=true&trackingId=" + trackingId;
}
示例3: addDetailMessage
import javax.faces.application.FacesMessage; //導入方法依賴的package包/類
public static void addDetailMessage(String message, FacesMessage.Severity severity) {
FacesMessage facesMessage = new FacesMessage("", message);
if (severity != null && severity != FacesMessage.SEVERITY_INFO) {
facesMessage.setSeverity(severity);
}
FacesContext.getCurrentInstance().addMessage(null, facesMessage);
}
示例4: adicionarMensagem
import javax.faces.application.FacesMessage; //導入方法依賴的package包/類
public void adicionarMensagem(String mensagem, Severity tipoMensagem) {
FacesContext fc = FacesContext.getCurrentInstance();
FacesMessage fm = new FacesMessage(mensagem);
fm.setSeverity(tipoMensagem);
fc.addMessage(null, fm);
}
示例5: addFacesMessage
import javax.faces.application.FacesMessage; //導入方法依賴的package包/類
private void addFacesMessage(BusinessException be) {
FacesMessage facesMessage = new FacesMessage();
if (has(be.getSummary())) {
facesMessage.setSummary(be.getSummary());
}
if (has(be.getDetail())) {
facesMessage.setDetail(be.getDetail());
}
if (has(be.getSeverity())) {
facesMessage.setSeverity(be.getSeverity());
} else {
facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
}
Messages.add(be.getFieldId(), facesMessage);
}