本文整理汇总了Java中javax.faces.context.FacesContext.addMessage方法的典型用法代码示例。如果您正苦于以下问题:Java FacesContext.addMessage方法的具体用法?Java FacesContext.addMessage怎么用?Java FacesContext.addMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.context.FacesContext
的用法示例。
在下文中一共展示了FacesContext.addMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTrackById
import javax.faces.context.FacesContext; //导入方法依赖的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: show
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void show() {
FacesContext instance = FacesContext.getCurrentInstance();
String msg;
if (StringUtils.isEmpty(template)) {
msg = text;
if (severity == null) { // If we are using text, and the developer didn't specify a severity => Assume ERROR.
severity = FacesMessage.SEVERITY_ERROR;
}
} else {
msg = messageContext.message().template(template).argument(arguments).toString();
if (severity == null) {
severity = determineSeverity(template);
}
}
instance.addMessage(clientId, new FacesMessage(severity, msg, msg));
if (clientId != null) {
UIComponent component = instance.getViewRoot().findComponent(clientId);
if (component instanceof UIInput && FacesMessage.SEVERITY_ERROR.equals(severity)) {
((UIInput) component).setValid(false);
}
}
resetData();
}
示例3: register
import javax.faces.context.FacesContext; //导入方法依赖的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;
}
示例4: rangeChange
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void rangeChange(RangeChangeEvent rce)
{
int oldStart = rce.getOldStart();
int oldEnd = rce.getOldEnd();
int newStart = rce.getNewStart();
int newEnd = rce.getNewEnd();
FacesContext context = FacesContext.getCurrentInstance();
String message = "Range changed from "
+ oldStart +"-"+oldEnd+" to "
+ newStart +"-"+newEnd;
context.addMessage(rce.getComponent().getClientId(context),
new FacesMessage(message));
_setStart(newStart);
_setEnd(newEnd);
_setNamesInRange(new ArrayList<String>(getNames().subList(_start, getEnd())));
}
示例5: addErrorMsg
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public static void addErrorMsg(String mensagem)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, mensagem, mensagem);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, fm);
}
示例6: valueChanged
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void valueChanged(ValueChangeEvent vce)
{
String oldValue = _toString(vce.getOldValue());
Object newValue = _toString(vce.getNewValue());
FacesContext context = FacesContext.getCurrentInstance();
String message =
"Value changed from " + oldValue + " to " + newValue;
context.addMessage(vce.getComponent().getClientId(context),
new FacesMessage(message));
}
示例7: validateFromAndToDate
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void validateFromAndToDate(final FacesContext context,
final UIComponent toValidate, final Object value) {
String clientId = toValidate.getClientId(context);
validator.setToDate(model.getToDate());
validator.setFromDate(model.getFromDate());
try {
validator.validate(context, toValidate, value);
} catch (ValidatorException ex) {
context.addMessage(
clientId,
new FacesMessage(FacesMessage.SEVERITY_ERROR, ex
.getLocalizedMessage(), null));
}
}
示例8: adicionarMensagem
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void adicionarMensagem(String mensagem, Severity tipoMensagem) {
FacesContext fc = FacesContext.getCurrentInstance();
FacesMessage fm = new FacesMessage(mensagem);
fm.setSeverity(tipoMensagem);
fc.addMessage(null, fm);
}
示例9: action
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public String action()
{
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage("Clicked on Chemical " + getName());
context.addMessage(null, message);
return null;
}
示例10: addWarningMsg
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public static void addWarningMsg(String mensagem,String idFormulario, String idComponente)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_WARN, mensagem, mensagem);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, fm);
RequestContext.getCurrentInstance().update(idFormulario+":"+idComponente);
}
示例11: apply
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@Override
public void apply(FacesContext context, UIComponent component)
{
// first, cleanup any messages left over from a previous test
// ((MFacesContext) context).clearMessages();
// Add any messages needed to run this suite of tests
Iterator<String> messageIds = _messages.keySet().iterator();
while (messageIds.hasNext())
{
String id = messageIds.next();
FacesMessage fm = _messages.get(id);
context.addMessage(id, fm);
}
}
示例12: action
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public String action()
{
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage("CLICKED ON ROW " + _int + ", " +
_string);
context.addMessage(null, message);
return null;
}
示例13: fileUploaded
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void fileUploaded(ValueChangeEvent event) throws IOException
{
UploadedFile file = (UploadedFile) event.getNewValue();
if (file != null)
{
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage(
"Uploaded file " + file.getFilename() +
" (" + file.getLength() + " bytes)"+". Bytes available to read: " +
file.getInputStream().available());
context.addMessage(event.getComponent().getClientId(context), message);
}
}
示例14: testFailover
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void testFailover()
{
FacesContext context = FacesContext.getCurrentInstance();
Map<String, Object> session =
context.getExternalContext().getSessionMap();
Map.Entry<String, Object> writing = null;
try
{
ObjectOutputStream oos =
new ObjectOutputStream(new ByteArrayOutputStream(2 << 16));
Iterator<Map.Entry<String, Object>> entries = session.entrySet().iterator();
while (entries.hasNext())
{
writing = entries.next();
oos.writeObject(writing.getValue());
context.addMessage(null,
new FacesMessage("Successfully serialized " + writing.getValue() + " [at " + writing.getKey() + "]"));
}
}
catch (IOException ioe)
{
context.addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Failed while outputting object " + writing.getValue() +
" [at " + writing.getKey() + "]",
ioe.getMessage()));
}
}
示例15: login
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
* Process login. Connect to server and move to folder display page.
*/
public String login()
{
try
{
// login to the IMAP server
Properties props = new Properties();
Session session = Session.getInstance(props, null);
Store store = session.getStore("imap");
store.connect(_server, _username, _password);
setStore(store);
setRootFolders(FolderData.toFolderData(this, store.getDefaultFolder().list()));
// TODO: Add logged in indicator to restrict access
_gotoFolder(null);
// Set up the user's preferences; in a real app, these would
// be persisted somewhere.
PreferencesData preferences = new PreferencesData();
setPreferences(preferences);
}
// catch all exceptions and report them as errors
catch (Exception e)
{
FacesMessage errorMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR,
e.getMessage(), null);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, errorMessage);
return null;
}
return "success";
}