本文整理汇总了Java中javax.faces.event.PhaseId.RENDER_RESPONSE属性的典型用法代码示例。如果您正苦于以下问题:Java PhaseId.RENDER_RESPONSE属性的具体用法?Java PhaseId.RENDER_RESPONSE怎么用?Java PhaseId.RENDER_RESPONSE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.faces.event.PhaseId
的用法示例。
在下文中一共展示了PhaseId.RENDER_RESPONSE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getListener
public PhaseListener getListener() {
return new PhaseListener() {
private static final long serialVersionUID = -66585096775189540L;
public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}
public void beforePhase(PhaseEvent event) {
unselectCategory();
}
public void afterPhase(PhaseEvent arg0) {
// nothing
}
};
}
示例2: processPartial
@Override
public void processPartial(PhaseId phaseId)
{
UIViewRoot viewRoot = _context.getViewRoot();
if (phaseId == PhaseId.APPLY_REQUEST_VALUES ||
phaseId == PhaseId.PROCESS_VALIDATIONS ||
phaseId == PhaseId.UPDATE_MODEL_VALUES)
{
_processExecute(viewRoot, phaseId);
}
else if (phaseId == PhaseId.RENDER_RESPONSE)
{
_processRender(viewRoot);
}
}
示例3: reportPhase
private void reportPhase (PhaseEvent event, boolean after) {
HttpSession session = (HttpSession) event.getFacesContext().getExternalContext().getSession(false);
if (session != null) {
if (after && event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
session.removeAttribute(PHASE);
} else {
if (!after) session.setAttribute(PHASE, event.getPhaseId());
}
}
if (!after && event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
//DumpView(event.getFacesContext());
}
//System.out.println ("**********************"+(after ? "AFTER " : "BEFORE ")+event.getPhaseId()+" session="+session); System.out.flush();
}
示例4: getStreamedPhoto
/**
* Can be used to render a image in the view with some image data
*
* @param data
* array of bytes with image data
* @return StreamedContent
*/
public StreamedContent getStreamedPhoto(byte[] data) {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent(FacesContext.getCurrentInstance()
.getExternalContext()
.getResourceAsStream("/static/img/default-image.png"));
// return new DefaultStreamedContent();
} else {
if (data != null) {
return new DefaultStreamedContent(
new ByteArrayInputStream(data));
} else {
return new DefaultStreamedContent(FacesContext
.getCurrentInstance().getExternalContext()
.getResourceAsStream("/static/img/default-image.png"));
}
}
}
示例5: getStreamedInsuranceIcon
public StreamedContent getStreamedInsuranceIcon() {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent();
} else {
String id = context.getExternalContext().getRequestParameterMap()
.get("id");
byte[] image = null;
for (Insurances in : insurances) {
if (in.getIdinsurances().toString().equals(id)) {
image = in.getIcon();
break;
}
}
if (image != null) {
return new DefaultStreamedContent(new ByteArrayInputStream(
image));
} else {
return new DefaultStreamedContent(FacesContext
.getCurrentInstance().getExternalContext()
.getResourceAsStream("/static/img/default-image.png"));
}
}
}
示例6: getStreamedIcon
public StreamedContent getStreamedIcon() {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent();
} else {
if (bean.getIcon() != null) {
return new DefaultStreamedContent(new ByteArrayInputStream(
bean.getIcon()));
} else {
return new DefaultStreamedContent(FacesContext
.getCurrentInstance().getExternalContext()
.getResourceAsStream("/static/img/default-image.png"));
}
}
}
示例7: getStreamedPhoto
public StreamedContent getStreamedPhoto() {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent();
} else {
if (bean.getPhoto() != null) {
return new DefaultStreamedContent(new ByteArrayInputStream(
bean.getPhoto()));
} else {
return new DefaultStreamedContent(FacesContext
.getCurrentInstance().getExternalContext()
.getResourceAsStream("/static/img/default-image.png"));
}
}
}
示例8: afterPhase
@Override
public void afterPhase(PhaseEvent event)
{
// Set an attribute on to the session just so that we can force the session to get serialized
// We target the invoke application phase as well since the redirects get issued at that stage.
if (event.getPhaseId() == PhaseId.INVOKE_APPLICATION || event.getPhaseId() == PhaseId.RENDER_RESPONSE)
{
final String METHOD_NAME = "afterPhase";
LOGGER.logp(Level.FINEST, CLASS_NAME, METHOD_NAME, "Adding a random attribute to the session map.");
Map<String, Object> sessionMap = event.getFacesContext().getExternalContext().getSessionMap();
if (sessionMap != null)
{
sessionMap.put("__timestamp__", System.currentTimeMillis());
}
}
}
示例9: beforePhase
/**
* Handle a notification that the processing for a particular phase of the
* request processing lifecycle is about to begin.
*/
public void beforePhase(PhaseEvent event) {
if(event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
FacesContext facesContext = event.getFacesContext();
restoreMessages(facesContext);
}
}
示例10: beforePhase
/**
* in RENDER_RESPONSE restore facesMessages
*/
public void beforePhase(PhaseEvent event) {
if (event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
FacesContext facesContext = event.getFacesContext();
restoreMessages(facesContext);
}
}
示例11: goToErrorPage
/**
* @param context
* @param e
* @throws Throwable
*/
private void goToErrorPage(FacesContext context, Throwable e) {
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
request.setAttribute(ERROR_EXCEPTION + "_stacktrace", e);
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
throw new FacesException(e);
}
if (e instanceof FileNotFoundException) {
logger.log(Level.WARNING,"File not found", e);
throw new FacesException(e);
}
request.setAttribute(ERROR_EXCEPTION_TYPE, e.getClass().getName());
request.setAttribute(ERROR_MESSAGE, e.getMessage());
request.setAttribute(ERROR_REQUEST_URI, request.getHeader("Referer"));
request.setAttribute(ERROR_STATUS_CODE, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
String errorPage = findErrorPage(e);
if (!has(errorPage)) {
String errorPageParam = context.getExternalContext().getInitParameter(Constants.InitialParams.ERROR_PAGE);
if (!has(errorPageParam)) {
errorPage = Constants.DEFAULT_ERROR_PAGE;
}
}
context.getApplication().getNavigationHandler().handleNavigation(context, null, errorPage);
context.renderResponse();
}
示例12: handleBusinessException
/**
* @param context
* @param e application business exception
*/
private void handleBusinessException(FacesContext context, BusinessException e) {
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
throw new FacesException(e);
}
if (has(e.getExceptionList())) {
for (BusinessException be : e.getExceptionList()) {
addFacesMessage(be);
}
} else { //Single exception
addFacesMessage(e);
}
validationFailed();
context.renderResponse();
}
示例13: getPhotoStreamedContent
/**
* Get photo as a stream. Parameter is expected to be present.
*
* @return StreamedContent for pf graphic image.
*/
public StreamedContent getPhotoStreamedContent() {
try
{
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE)
{
// So, we're rendering the view. Return a stub StreamedContent so that it will generate right URL.
return new DefaultStreamedContent();
}
// So, browser is requesting the image. Get ID value from actual request param.
String photoIdStr = context.getExternalContext().getRequestParameterMap().get("photoId");
if (photoIdStr == null)
{
log.error("No photoParamId found!!");
return null;
}
Photo photo = photoTableModel.getRowData(photoIdStr);
if (photo == null)
{
log.error("Failed to find photo in map with id " + photoIdStr);
return null;
}
return new DefaultStreamedContent(new ByteArrayInputStream(photo.getPhotoContent()), photo.getPhotoType());
}
catch (Exception e) {
log.error("Failed to find photo", e);
}
return null;
}
示例14: getPhaseId
/**
* @see javax.faces.event.PhaseListener#getPhaseId()
*/
@Override
public PhaseId getPhaseId() {
// Only listen during the render response phase.
return PhaseId.RENDER_RESPONSE;
}
示例15: afterPhase
/**
* @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent)
*/
public void afterPhase(PhaseEvent event)
{
if (logger.isDebugEnabled())
{
if (event.getPhaseId() == PhaseId.RENDER_RESPONSE)
{
printComponentTree(FacesContext.getCurrentInstance().getViewRoot());
}
logger.debug("********** Exiting phase: " + event.getPhaseId().toString());
}
}