本文整理汇总了Java中javax.faces.context.FacesContext.responseComplete方法的典型用法代码示例。如果您正苦于以下问题:Java FacesContext.responseComplete方法的具体用法?Java FacesContext.responseComplete怎么用?Java FacesContext.responseComplete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.context.FacesContext
的用法示例。
在下文中一共展示了FacesContext.responseComplete方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: login
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void login() {
FacesContext context = FacesContext.getCurrentInstance();
Credential credential = new UsernamePasswordCredential(username, new Password(password));
AuthenticationStatus status = securityContext.authenticate(
getRequest(context),
getResponse(context),
withParams()
.credential(credential)
.newAuthentication(!continued)
.rememberMe(rememberMe)
);
LOG.info("authentication result:" + status);
if (status.equals(SEND_CONTINUE)) {
// Authentication mechanism has send a redirect, should not
// send anything to response from JSF now.
context.responseComplete();
} else if (status.equals(SEND_FAILURE)) {
addError(context, "Authentication failed");
}
}
示例2: createResponse
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
private void createResponse(byte[] buf) throws IOException {
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) fc
.getExternalContext().getResponse();
String filename = generateFileName();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachement; filename=\""
+ filename + "\"");
response.setContentLength(buf.length);
OutputStream out;
out = response.getOutputStream();
out.write(buf);
out.flush();
out.close();
fc.responseComplete();
}
示例3: handleOrganizationAuthoritiesException
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
*
*/
private static void handleOrganizationAuthoritiesException() {
FacesContext fc = FacesContext.getCurrentInstance();
// distinguish old/new portal by means of relative marketplace url
HttpServletRequest request = JSFUtils.getRequest();
if (request.getServletPath().startsWith(Marketplace.MARKETPLACE_ROOT)) {
fc.getApplication()
.getNavigationHandler()
.handleNavigation(fc, "bean.actionName",
"InsufficientOrganizationAuthoritiesMPL");
} else {
fc.getApplication()
.getNavigationHandler()
.handleNavigation(fc, "bean.actionName",
"InsufficientOrganizationAuthorities");
}
fc.responseComplete();
}
示例4: handleInvalidSession
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
*
*/
public static void handleInvalidSession() {
FacesContext fc = FacesContext.getCurrentInstance();
// distinguish old/new portal by means of relative marketplace url
HttpServletRequest request = JSFUtils.getRequest();
if (request.getServletPath().startsWith(Marketplace.MARKETPLACE_ROOT)) {
fc.getApplication()
.getNavigationHandler()
.handleNavigation(fc, "bean.actionName",
"marketplace/login");
} else {
fc.getApplication().getNavigationHandler()
.handleNavigation(fc, "bean.actionName", "login");
}
fc.responseComplete();
}
示例5: redirect
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@Override
public void redirect(final String url) throws IOException
{
_checkResponse();
if (_servletResponse instanceof HttpServletResponse)
{
_httpServletResponse.sendRedirect(url);
FacesContext fc = FacesContext.getCurrentInstance();
if (fc != null)
{
fc.responseComplete();
}
}
else
{
throw new IllegalArgumentException(_LOG.getMessage(
"ONLY_HTTPSERVLETRESPONSE_SUPPORTED"));
}
}
示例6: _sendError
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
private static void _sendError(FacesContext context, String message)
{
if (context.getResponseComplete())
{
return;
}
ExternalContext external = context.getExternalContext();
try
{
external.responseSendError(500, message);
}
catch (IOException e)
{
_LOG.warning(e);
}
finally
{
context.responseComplete();
}
}
示例7: concurrentModification
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
* execute navigation rule: go to destination specified for concurrent
* modification situation
*/
private void concurrentModification() {
FacesContext ctx = FacesContext.getCurrentInstance();
ctx.getApplication().getNavigationHandler()
.handleNavigation(ctx, "", CONCURRENT_MODIFICATION_ERROR);
ctx.responseComplete();
}
示例8: concurrentModification
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
* execute navigation rule: go to destination specified for concurrent
* modification situation
*/
void concurrentModification() {
FacesContext ctx = FacesContext.getCurrentInstance();
ctx.getApplication().getNavigationHandler()
.handleNavigation(ctx, "", CONCURRENT_MODIFICATION_ERROR);
ctx.responseComplete();
}
示例9: exportTranslations
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
* Export the translations for the current supplier into an excel file.
*
* @return the logical outcome.
* @throws IOException
* Thrown in case the access to the uploaded file failed.
*/
public String exportTranslations() throws IOException {
byte[] buf = createExcel();
if (buf == null) {
return OUTCOME_ERROR;
}
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) fc
.getExternalContext().getResponse();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd");
String filename = sdf.format(Calendar.getInstance().getTime())
+ "_Translations.xls";
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachement; filename=\""
+ filename + "\"");
response.setContentLength(buf.length);
OutputStream out;
out = response.getOutputStream();
out.write(buf);
out.flush();
out.close();
fc.responseComplete();
return null;
}
示例10: _checkSkinPregeneration
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
private void _checkSkinPregeneration(FacesContext context, String viewId)
{
if (_skinPregenerationEnabled && !SkinPregenerationService.isPregenerationRequest(viewId))
{
ExternalContext external = context.getExternalContext();
String message = _LOG.getMessage("SKIN_PREGEN_ENABLED");
_LOG.severe(message);
_sendError(external, message);
// We don't explicitly short-circuit/exception out. Calling
// responseComplete() achieves the same result (ie. prevents
// subsequent processing/rendering) more gracefully.
context.responseComplete();
}
}
示例11: returnFromDialog
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public boolean returnFromDialog(
FacesContext context,
Object returnValue)
{
if (!_supportsSeparateWindow(context))
return false;
try
{
boolean usePopup = usePopupForDialog(context, RequestContext.getCurrentInstance());
// Deliver callback in the context of the launching window
// This is required to work around problems in Mozilla
// with cross frame XmlHttpRequest invocation
Writer out = _getHtmlWriter(context);
if (usePopup)
{
out.write("<script>");
out.write("parent.TrPopupDialog._returnFromDialog();");
out.write("</script>");
}
else
{
RequestContext afC = RequestContext.getCurrentInstance();
String returnId = (String) afC.getPageFlowScope().get(_RETURN_ID);
if (returnId == null)
throw new IllegalStateException(_LOG.getMessage(
"NO_RETURNID_AVAILABLE_FOR_RETURNING_FROM_DIALOG"));
// http://issues.apache.org/jira/browse/ADFFACES-191 - handling alt-f4
// Following code is now called from onunload JS function - see FredJSP
// out.write("var callback = 'ADFDialogReturn[" + returnId + "]()';");
// out.write("top.opener.setTimeout(callback, 1);");
out.write("<script>");
out.write("top.close()");
out.write("</script>");
_LOG.fine("Returning from dialog using return ID {0}", returnId);
}
out.close();
context.responseComplete();
}
catch (IOException ioe)
{
_LOG.warning(ioe);
}
return true;
}
示例12: returnFromDialog
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean returnFromDialog(Object returnValue,
Map<Object, Object> returnParameters)
{
FacesContext context = _getFacesContext();
context.getExternalContext().getSessionMap().
put(_DIALOG_RETURN_KEY, new Object[]{returnValue, returnParameters});
Object usedRenderKit = _getPageFlowScope().get(_USED_RENDER_KIT_KEY);
if (usedRenderKit == null)
{
_LOG.warning("RETURNFROMDIALOG_KEY_NOT_AVAILABLE");
}
if (Boolean.TRUE.equals(usedRenderKit))
{
DialogRenderKitService service = _getDialogRenderKitService(context);
if ((service != null) &&
service.returnFromDialog(context, returnValue))
return true;
}
// If the render kit didn't handle it, then pop the view ourselves
popView(true);
UIViewRoot poppedView = context.getViewRoot();
// And, if there's parameters that need to be passed to the popped page,
// do that; we'll mark the response as complete, because we'll need
// the AdfFacesFilter to re-execute the faces lifecycle with the
// new parameters
Map<Object, Object> launchParameters = (Map<Object, Object>)
poppedView.getAttributes().get(RequestContextImpl.LAUNCH_PARAMETERS);
Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
if (launchParameters != null)
{
// Store the parameters and the UIViewRoot for (respectively)
// AdfFacesFilterImpl and ViewHandlerImpl
poppedView.getAttributes().remove(RequestContextImpl.LAUNCH_PARAMETERS);
requestMap.put(RequestContextImpl.LAUNCH_PARAMETERS, launchParameters);
requestMap.put(RequestContextImpl.LAUNCH_VIEW, poppedView);
context.responseComplete();
_LOG.fine("Returned from dialog and re-executing lifecycle for {0}",
poppedView.getViewId());
}
requestMap.put(DIALOG_RETURN, Boolean.TRUE);
return false;
}
示例13: downloadAttachment
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public String downloadAttachment() throws IOException, MessagingException
{
if (_attachmentToDownload == null)
{
_LOG.severe("No attachment available");
return null;
}
_message.getMessage().getFolder().open(Folder.READ_ONLY);
InputStream in = _attachmentToDownload.getInputStream();
FacesContext context = FacesContext.getCurrentInstance();
// Get the ServletResponse; nothing on ExternalContext is sufficient
ServletResponse response = (ServletResponse)
context.getExternalContext().getResponse();
response.setContentType(_attachmentToDownload.getContentType());
// If the size of the attachment is known, pass that on.
int size = _attachmentToDownload.getSize();
if (size >= 0)
{
response.setContentLength(size);
}
if (_LOG.isLoggable(Level.INFO))
_LOG.info("Downloading content+ [size=" + size +",contentType=" +
_attachmentToDownload.getContentType() + "]");
if (response instanceof HttpServletResponse)
{
String filename = _attachmentToDownload.getFileName();
if (filename != null)
{
((HttpServletResponse) response).setHeader(
"Content-disposition",
"attachment; filename=\"" + filename + "\"");
}
}
// Pass the text along, 128K at a time.
try
{
OutputStream out = response.getOutputStream();
try
{
byte[] buffer = new byte[131072];
while (true)
{
int count = in.read(buffer);
if (count < 0)
break;
out.write(buffer, 0, count);
}
}
// Close up the response
finally
{
// And tell JSF that we handled everything
context.responseComplete();
out.close();
}
}
// And make sure the folder got closed
finally
{
_message.getMessage().getFolder().close(false);
}
return null;
}
示例14: writeContentToResponse
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
* Writes the given content to the response as attachment of the given type
* with the given filename.
*
* @param content
* the data
* @param filename
* the wanted filename
* @param contentType
* the wanted content type
* @throws IOException
*/
public static void writeContentToResponse(byte[] content, String filename,
String contentType) throws IOException {
FacesContext fc = FacesContext.getCurrentInstance();
writeContentToResponse(content, filename, contentType, fc);
fc.responseComplete();
}