本文整理汇总了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);
}