本文整理汇总了Java中javax.portlet.PortletSession.removeAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java PortletSession.removeAttribute方法的具体用法?Java PortletSession.removeAttribute怎么用?Java PortletSession.removeAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.portlet.PortletSession
的用法示例。
在下文中一共展示了PortletSession.removeAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeAttribute
import javax.portlet.PortletSession; //导入方法依赖的package包/类
@Override
public void removeAttribute(String name, int scope) {
if (scope == SCOPE_REQUEST) {
if (isRequestActive()) {
this.request.removeAttribute(name);
removeRequestDestructionCallback(name);
}
}
else {
PortletSession session = getSession(false);
if (session != null) {
if (scope == SCOPE_GLOBAL_SESSION) {
session.removeAttribute(name, PortletSession.APPLICATION_SCOPE);
this.globalSessionAttributesToUpdate.remove(name);
}
else {
session.removeAttribute(name);
this.sessionAttributesToUpdate.remove(name);
}
}
}
}
示例2: portalGuestAuthenticate
import javax.portlet.PortletSession; //导入方法依赖的package包/类
/**
* For no previous authentication or forced Guest - attempt Guest access
*
* @param ctx WebApplicationContext
* @param auth AuthenticationService
*/
private static User portalGuestAuthenticate(WebApplicationContext ctx, PortletSession session, AuthenticationService auth)
{
User user = AuthenticationHelper.portalGuestAuthenticate(ctx, auth);
if (user != null)
{
// store the User object in the Session - the authentication servlet will then proceed
session.setAttribute(AuthenticationHelper.AUTHENTICATION_USER, user, PortletSession.APPLICATION_SCOPE);
// Set the current locale
I18NUtil.setLocale(getLanguage(session));
// remove the session invalidated flag
session.removeAttribute(AuthenticationHelper.SESSION_INVALIDATED);
}
return user;
}
示例3: copyToRequest
import javax.portlet.PortletSession; //导入方法依赖的package包/类
/**
* Copia os valores para a requisição.
*
* Se o valor existir na sessão, copia para a requisição Se não existir, e o
* objeto tiver sido informado, utiliza-o Se não o objeto não for informado,
* tenta obter da sessão. Se não conseguir, utiliza o default
*
* @param req
* @param att
* @param propName
* @param obj
* @param defaultValue
*/
public static void copyToRequest(PortletRequest req, String att, String propName, Object obj, Object defaultValue) {
PortletSession session = req.getPortletSession(false);
if (session != null) {
Object val = session.getAttribute("FLASH_" + att);
if (val != null) {
req.setAttribute(att, val);
session.removeAttribute("FLASH_" + att);
return;
}
}
// Não existe na sessão
if (obj == null) {
req.setAttribute(att, defaultValue);
} else {
// Obtem o valor do objeto e copia - aqui apenas strings
try {
Object value = PropertyUtils.getProperty(obj, propName);
req.setAttribute(att, value);
} catch (Exception e) {
LOG.error("Erro ao copiar propriedade " + propName + " da classe " + obj.getClass().getName(), e);
}
}
}
示例4: render
import javax.portlet.PortletSession; //导入方法依赖的package包/类
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
long tid = Thread.currentThread().getId();
portletReq.setAttribute(THREADID_ATTR, tid);
PrintWriter writer = portletResp.getWriter();
PortletSession ps = portletReq.getPortletSession();
String msg = (String) ps.getAttribute(RESULT_ATTR_PREFIX + V2DISPATCHERTESTS3S_SPEC2_19_INCLUDESERVLETACTION_DISPATCH4);
if (msg != null) {
writer.write("<p>" + msg + "</p><br/>\n");
ps.removeAttribute(RESULT_ATTR_PREFIX + V2DISPATCHERTESTS3S_SPEC2_19_INCLUDESERVLETACTION_DISPATCH4);
}
/* TestCase: V2DispatcherTests3S_SPEC2_19_IncludeServletAction_dispatch4 */
/* Details: "The parameters associated with a request dispatcher are */
/* scoped only for the duration of the include or forward call" */
{
PortletURL aurl = portletResp.createActionURL();
aurl.setParameters(portletReq.getPrivateParameterMap());
TestButton tb = new TestButton(V2DISPATCHERTESTS3S_SPEC2_19_INCLUDESERVLETACTION_DISPATCH4, aurl);
tb.writeTo(writer);
}
}
示例5: checkRemoveAppScopedAttribute
import javax.portlet.PortletSession; //导入方法依赖的package包/类
protected TestResult checkRemoveAppScopedAttribute(PortletSession session) {
TestResult result = new TestResult();
result.setDescription("Remove an application scoped session attribute "
+ "and ensure it's null.");
result.setSpecPLT("15.3");
session.setAttribute(KEY, VALUE, PortletSession.APPLICATION_SCOPE);
session.removeAttribute(KEY, PortletSession.APPLICATION_SCOPE);
Object value = session.getAttribute(KEY, PortletSession.APPLICATION_SCOPE);
if (value == null) {
result.setReturnCode(TestResult.PASSED);
} else {
TestUtils.failOnAssertion("session attribute", value, null, result);
}
return result;
}
示例6: setSessionAttribute
import javax.portlet.PortletSession; //导入方法依赖的package包/类
/**
* Set the session attribute with the given name to the given value in the given scope.
* Removes the session attribute if value is {@code null}, if a session existed at all.
* Does not create a new session if not necessary!
* @param request current portlet request
* @param name the name of the session attribute
* @param value the value of the session attribute
* @param scope session scope of this attribute
*/
public static void setSessionAttribute(PortletRequest request, String name, Object value, int scope) {
Assert.notNull(request, "Request must not be null");
if (value != null) {
request.getPortletSession().setAttribute(name, value, scope);
}
else {
PortletSession session = request.getPortletSession(false);
if (session != null) {
session.removeAttribute(name, scope);
}
}
}
示例7: processAction
import javax.portlet.PortletSession; //导入方法依赖的package包/类
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {
log.debug("==== processAction called ====");
PortletSession pSession = request.getPortletSession(true);
// Our first challenge is to figure out which action we want to take
// The view selects the "next action" either as a URL parameter
// or as a hidden field in the POST data - we check both
String doCancel = request.getParameter("sakai.cancel");
String doUpdate = request.getParameter("sakai.update");
// Our next challenge is to pick which action the previous view
// has told us to do. Note that the view may place several actions
// on the screen and the user may have an option to pick between
// them. Make sure we handle the "no action" fall-through.
pSession.removeAttribute("error.message");
if ( doCancel != null ) {
response.setPortletMode(PortletMode.VIEW);
} else if ( doUpdate != null ) {
processActionEdit(request, response);
} else {
log.debug("Unknown action");
response.setPortletMode(PortletMode.VIEW);
}
log.debug("==== End of ProcessAction ====");
}
示例8: clearErrorMessage
import javax.portlet.PortletSession; //导入方法依赖的package包/类
public static void clearErrorMessage(PortletRequest request)
{
PortletSession pSession = request.getPortletSession(true);
pSession.removeAttribute("error.message");
pSession.removeAttribute("error.output");
pSession.removeAttribute("error.map");
}
示例9: clearSession
import javax.portlet.PortletSession; //导入方法依赖的package包/类
private void clearSession(PortletRequest request)
{
PortletSession pSession = request.getPortletSession(true);
pSession.removeAttribute("sakai.url");
pSession.removeAttribute("sakai.widget");
pSession.removeAttribute("sakai.descriptor");
pSession.removeAttribute("sakai.attemptdescriptor");
for (String element : fieldList) {
pSession.removeAttribute("sakai."+element);
}
}
示例10: onLogOut
import javax.portlet.PortletSession; //导入方法依赖的package包/类
public static String onLogOut(Object req)
{
PortletRequest portletReq = null;
if (req instanceof ServletRequest)
{
portletReq = (PortletRequest) ((ServletRequest) req).getAttribute("javax.portlet.request");
}
else if (req instanceof PortletRequest)
{
portletReq = (PortletRequest) req;
}
if (portletReq == null)
{
return null;
}
// remove all objects from our session by hand
// we do this as invalidating the Portal session would invalidate all other portlets!
PortletSession session = portletReq.getPortletSession();
SessionUser user = (SessionUser) session.getAttribute(AuthenticationHelper.AUTHENTICATION_USER,
PortletSession.APPLICATION_SCOPE);
Enumeration<String> i = session.getAttributeNames();
while (i.hasMoreElements())
{
session.removeAttribute(i.nextElement());
}
session.setAttribute(AuthenticationHelper.SESSION_INVALIDATED, true);
return user == null ? null : user.getTicket();
}
示例11: recuperaLoginDaSessao
import javax.portlet.PortletSession; //导入方法依赖的package包/类
private void recuperaLoginDaSessao(RenderRequest renderRequest) {
String login = null;
PortletSession session = renderRequest.getPortletSession(false);
if (session != null) {
login = (String) session.getAttribute("login");
session.removeAttribute("login");
}
renderRequest.setAttribute("login", login);
}
示例12: render
import javax.portlet.PortletSession; //导入方法依赖的package包/类
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
long tid = Thread.currentThread().getId();
portletReq.setAttribute(THREADID_ATTR, tid);
PrintWriter writer = portletResp.getWriter();
PortletSession ps = portletReq.getPortletSession();
String msg = (String) ps.getAttribute(RESULT_ATTR_PREFIX + V2DISPATCHERTESTS3S_SPEC2_19_FORWARDJSPACTION_DISPATCH4,
APPLICATION_SCOPE);
if (msg != null) {
writer.write("<p>" + msg + "</p><br/>\n");
ps.removeAttribute(RESULT_ATTR_PREFIX + V2DISPATCHERTESTS3S_SPEC2_19_FORWARDJSPACTION_DISPATCH4, APPLICATION_SCOPE);
}
/* TestCase: V2DispatcherTests3S_SPEC2_19_ForwardJSPAction_dispatch4 */
/* Details: "The parameters associated with a request dispatcher are */
/* scoped only for the duration of the include or forward call" */
{
PortletURL aurl = portletResp.createActionURL();
aurl.setParameters(portletReq.getPrivateParameterMap());
TestButton tb = new TestButton(V2DISPATCHERTESTS3S_SPEC2_19_FORWARDJSPACTION_DISPATCH4, aurl);
tb.writeTo(writer);
}
}
示例13: tentarAutenticar
import javax.portlet.PortletSession; //导入方法依赖的package包/类
private boolean tentarAutenticar() {
MethodKey method = new MethodKey("com.liferay.portlet.login.util.LoginUtil", "login", new Class[] { HttpServletRequest.class,
HttpServletResponse.class, String.class, String.class, boolean.class, String.class });
ActionRequest request = (ActionRequest) LiferayFacesContext.getInstance().getPortletRequest();
ActionResponse response = (ActionResponse) LiferayFacesContext.getInstance().getPortletResponse();
HttpServletRequest httpServletRequest = getHttpServletRequest(request);
try {
PortalClassInvoker.invoke(false, method, httpServletRequest, PortalUtil.getHttpServletResponse(response), email, senha, false,
CompanyConstants.AUTH_TYPE_EA);
PortletSession session = request.getPortletSession(false);
if (session != null)
session.removeAttribute("email");
return true;
} catch (Exception e) {
if (e instanceof AuthException) {
Throwable cause = e.getCause();
if (cause != null)
SessionErrors.add(request, cause.getClass());
else
SessionErrors.add(request, e.getClass());
} else {
SessionErrors.add(request, e.getClass());
}
return false;
}
}
示例14: clearFlashScope
import javax.portlet.PortletSession; //导入方法依赖的package包/类
/**
* Limpa o escopo flash
*
* @param req
*/
public static void clearFlashScope(PortletRequest req) {
PortletSession session = req.getPortletSession(false);
if (session == null)
return;
Enumeration<String> attNames = session.getAttributeNames();
while (attNames.hasMoreElements()) {
String att = attNames.nextElement();
if (att.startsWith("FLASH_"))
session.removeAttribute(att);
}
}
示例15: render
import javax.portlet.PortletSession; //导入方法依赖的package包/类
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
throws PortletException, IOException {
long tid = Thread.currentThread().getId();
portletReq.setAttribute(THREADID_ATTR, tid);
PrintWriter writer = portletResp.getWriter();
PortletSession ps = portletReq.getPortletSession();
String msg = (String) ps.getAttribute(RESULT_ATTR_PREFIX + "DispatcherReqRespTests5S_SPEC2_19_ForwardServletActionResponse", APPLICATION_SCOPE);
if (msg != null) {
writer.write("<p>" + msg + "</p><br/>\n");
ps.removeAttribute(RESULT_ATTR_PREFIX + "DispatcherReqRespTests5S_SPEC2_19_ForwardServletActionResponse", APPLICATION_SCOPE);
}
/* TestCase: V2DispatcherReqRespTests5S_SPEC2_19_ForwardServletActionResponse_sendRedirect */
/* Details: "In a target servlet of a forward in the Action phase, */
/* the method HttpServletResponse.sendRedirect must provide the same */
/* functionality as ActionResponse.sendRedirect" */
{
PortletURL aurl = portletResp.createActionURL();
aurl.setParameters(portletReq.getPrivateParameterMap());
TestButton tb = new TestButton(V2DISPATCHERREQRESPTESTS5S_SPEC2_19_FORWARDSERVLETACTIONRESPONSE_SENDREDIRECT, aurl);
tb.writeTo(writer);
}
}
开发者ID:apache,项目名称:portals-pluto,代码行数:29,代码来源:DispatcherReqRespTests5S_SPEC2_19_ForwardServletActionResponse.java