com.opensymphony.xwork2.util.ValueStack Java Examples
The following examples show how to use
com.opensymphony.xwork2.util.ValueStack.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PageSettingsActionAspectTest.java From entando-components with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); ActionContext actionContext = Mockito.mock(ActionContext.class); ServletContext servletContext = Mockito.mock(ServletContext.class); request.setSession(new MockHttpSession(servletContext)); when(actionContext.getLocale()).thenReturn(Locale.ENGLISH); ValueStack valueStack = Mockito.mock(ValueStack.class); Map<String, Object> context = new HashMap<>(); Container container = Mockito.mock(Container.class); XWorkConverter conv = Mockito.mock(XWorkConverter.class); when(container.getInstance(XWorkConverter.class)).thenReturn(conv); when(conv.convertValue(Mockito.any(Map.class), Mockito.any(Object.class), Mockito.any(Class.class))).thenAnswer(new Answer<Object>() { public Object answer(InvocationOnMock invocation) throws Throwable { return "VALUE"; } }); context.put(ActionContext.CONTAINER, container); when(valueStack.getContext()).thenReturn(context); when(actionContext.getValueStack()).thenReturn(valueStack); when(actionContext.get(ServletActionContext.HTTP_REQUEST)).thenReturn(request); ServletActionContext.setContext(actionContext); when(joinPoint.getTarget()).thenReturn(pageSettingsAction); when(textProvider.getText(ArgumentMatchers.anyString(), ArgumentMatchers.anyList())).thenReturn("text"); }
Example #2
Source File: HookPointTag.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
@Override public int doStartTag() throws JspException { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); ValueStack stack = this.getStack(); try { List<HookPointElementContainer> containers = extractElements(request); if (containers.size()>0) { stack.getContext().put(this.getObjectName(), containers); stack.setValue("#attr['" + this.getObjectName() + "']", containers, false); return EVAL_BODY_INCLUDE; } } catch (Throwable t) { throw new JspException("Error detected ", t); } return super.doStartTag(); }
Example #3
Source File: PluginsSubMenuTag.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
@Override public int doStartTag() throws JspException { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); WebApplicationContext wac = ApsWebApplicationUtils.getWebApplicationContext(request); List<PluginSubMenuContainer> containters = new ArrayList<PluginSubMenuContainer>(); ValueStack stack = this.getStack(); try { String[] beanNames = wac.getBeanNamesForType(PluginSubMenuContainer.class); for (int i=0; i<beanNames.length; i++) { PluginSubMenuContainer container = (PluginSubMenuContainer) wac.getBean(beanNames[i]); containters.add(container); } if (containters.size()>0) { stack.getContext().put(this.getObjectName(), containters); stack.setValue("#attr['" + this.getObjectName() + "']", containters, false); return EVAL_BODY_INCLUDE; } } catch (Throwable t) { throw new JspException("Error creating the plugins menu list", t); } return super.doStartTag(); }
Example #4
Source File: UserShortcutsConfigTag.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
@Override public int doEndTag() throws JspException { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); try { UserConfigBean config = (UserConfigBean) request.getSession().getAttribute(MyShortcutConfigAction.SESSION_PARAM_MY_SHORTCUTS); UserDetails currentUser = (UserDetails) request.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER); if (null == config || !currentUser.getUsername().equals(config.getUsername())) { request.getSession().removeAttribute(MyShortcutConfigAction.SESSION_PARAM_MY_SHORTCUTS); IShortcutManager shortcutManager = (IShortcutManager) ApsWebApplicationUtils.getBean(ApsAdminSystemConstants.SHORTCUT_MANAGER, this.pageContext); config = shortcutManager.getUserConfigBean(currentUser); } if (null != this.getVar()) { ValueStack stack = this.getStack(); stack.getContext().put(this.getVar(), config); stack.setValue("#attr['" + this.getVar() + "']", config, false); } } catch (Throwable t) { _logger.error("Error on doStartTag", t); throw new JspException("Error on doStartTag", t); } return super.doEndTag(); }
Example #5
Source File: ShortcutListTag.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
@Override public int doStartTag() throws JspException { UserDetails currentUser = (UserDetails) this.pageContext.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER); try { Object retval = null; IShortcutManager shortcutManager = (IShortcutManager) ApsWebApplicationUtils.getBean(ApsAdminSystemConstants.SHORTCUT_MANAGER, this.pageContext); List<Shortcut> myShortcuts = shortcutManager.getAllowedShortcuts(currentUser); if (this.getType().equalsIgnoreCase(TYPE_LIST_OBJECT)) { retval = (Object) myShortcuts; } else if (this.getType().equalsIgnoreCase(TYPE_LIST_ITEMS)) { retval = (Object) this.getAllowedShortcutSelectItems(myShortcuts, currentUser); } else { _logger.warn("Invalid param for attribute 'value'. Expected '{}' or '{}' but was {}", TYPE_LIST_ITEMS, TYPE_LIST_OBJECT, this.getType()); } ValueStack stack = super.getStack(); stack.getContext().put(this.getVar(), retval); stack.setValue("#attr['" + this.getVar() + "']", retval, false); } catch (Throwable t) { _logger.error("Error extracting shortcuts for user '{}'", currentUser.getUsername() , t); throw new JspException("Error extracting shortcuts", t); } return super.doStartTag(); }
Example #6
Source File: ActivityStreamLastUpdateTag.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
@Override public int doEndTag() throws JspException { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); try { IActionLogManager loggerManager = (IActionLogManager) ApsWebApplicationUtils.getBean(SystemConstants.ACTION_LOGGER_MANAGER, this.pageContext); UserDetails currentUser = (UserDetails) request.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER); Date lastUpdate = loggerManager.lastUpdateDate(currentUser); if (null != this.getVar()) { ValueStack stack = this.getStack(); stack.getContext().put(this.getVar(), lastUpdate); stack.setValue("#attr['" + this.getVar() + "']", lastUpdate, false); } } catch (Throwable t) { _logger.error("Error on doStartTag", t); throw new JspException("Error on doStartTag", t); } return super.doEndTag(); }
Example #7
Source File: ActivityStreamTag.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
@Override public int doEndTag() throws JspException { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); try { IActionLogManager loggerManager = (IActionLogManager) ApsWebApplicationUtils.getBean(SystemConstants.ACTION_LOGGER_MANAGER, this.pageContext); UserDetails currentUser = (UserDetails) request.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER); FieldSearchFilter limitFilter = new FieldSearchFilter(10, 0); FieldSearchFilter[] filters = {limitFilter}; List<Integer> ids = loggerManager.getActivityStream(filters, currentUser); if (null != this.getVar()) { ValueStack stack = this.getStack(); stack.getContext().put(this.getVar(), ids); stack.setValue("#attr['" + this.getVar() + "']", ids, false); } } catch (Throwable t) { _logger.error("Error on doStartTag", t); //ApsSystemUtils.logThrowable(t, this, "doStartTag"); throw new JspException("Error on doStartTag", t); } return super.doEndTag(); }
Example #8
Source File: CmsAdminPagerTag.java From entando-components with GNU Lesser General Public License v3.0 | 6 votes |
@Override public int doStartTag() throws JspException { ServletRequest request = this.pageContext.getRequest(); try { Object realPagerId = this.findValue(this.getPagerId()); Integer realTotal = Integer.parseInt(this.findValue(this.getTotal()).toString()); Integer realMaxSize = Integer.parseInt(this.findValue(this.getMaxSize()).toString()); ValueStack stack = this.getStack(); AdminPagerTagHelper helper = this.getPagerHelper(); IPagerVO pagerVo = helper.getPagerVO(Arrays.asList(new String[realTotal]), realPagerId.toString(), realMaxSize, true, this.getOffset(), request); stack.getContext().put(this.getObjectName(), pagerVo); stack.setValue("#attr['" + this.getObjectName() + "']", pagerVo, false); } catch (Exception e) { logger.error("Error creating the pager", e); throw new JspException("Error creating the pager", e); } return EVAL_BODY_INCLUDE; }
Example #9
Source File: ContentStepTag.java From entando-components with GNU Lesser General Public License v3.0 | 6 votes |
@Override public int doStartTag() throws JspException { IContentWorkFlowActionHelper helper = (IContentWorkFlowActionHelper) ApsWebApplicationUtils.getBean("jpcontentworkflowContentActionHelper", pageContext); try { Content content = this.getContent(); String stepCode = null; if (this.isNextStep()) { stepCode = helper.getNextStep(content.getStatus(), content.getTypeCode()); } else { stepCode = helper.getPreviousStep(content.getStatus(), content.getTypeCode()); } if (null != this.getVar()) { ValueStack stack = this.getStack(); stack.getContext().put(this.getVar(), stepCode); stack.setValue("#attr['" + this.getVar() + "']", stepCode, false); } else { this.pageContext.getOut().print(stepCode); } } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "doStartTag"); throw new JspException("Error on doStartTag", t); } return super.doStartTag(); }
Example #10
Source File: ContentStepsTag.java From entando-components with GNU Lesser General Public License v3.0 | 6 votes |
@Override public int doStartTag() throws JspException { IContentWorkflowManager manager = (IContentWorkflowManager) ApsWebApplicationUtils.getBean(JpcontentworkflowSystemConstants.CONTENT_WORKFLOW_MANAGER, pageContext); try { Content content = this.getContent(); List<Step> steps = manager.getSteps(content.getTypeCode()); ValueStack stack = this.getStack(); stack.getContext().put(this.getVar(), steps); stack.setValue("#attr['" + this.getVar() + "']", steps, false); } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "doStartTag"); throw new JspException("Error on doStartTag", t); } return super.doStartTag(); }
Example #11
Source File: postInterceptor.java From Mall-Server with MIT License | 6 votes |
/** * 只允许POST访问拦截器 * @param actionInvocation * @return * @throws Exception */ @Override public String intercept(ActionInvocation actionInvocation) throws Exception { // 解决跨域 HttpServletResponse res = ServletActionContext.getResponse(); res.setHeader("Access-Control-Allow-Origin", "*"); res.setHeader("Access-Control-Allow-Credentials", "true"); res.setHeader("Access-Control-Allow-Methods", "*"); res.setHeader("Access-Control-Allow-Headers", "Content-Type,Access-Token"); res.setHeader("Access-Control-Expose-Headers", "*"); String method = ServletActionContext.getRequest().getMethod(); if (method.equals("POST")) { actionInvocation.invoke(); return null; } else { ActionContext context = ActionContext.getContext(); Map<String, Object> jsonResult = new HashMap<String, Object>(); jsonResult.put("rcode", 1); jsonResult.put("message", "just allow post method"); jsonResult.put("result", ""); ValueStack stack = context.getValueStack(); stack.set("jsonResult", jsonResult); return "success"; } }
Example #12
Source File: authInterceptor.java From Mall-Server with MIT License | 6 votes |
@Override public String intercept(ActionInvocation actionInvocation) throws Exception { String token = ServletActionContext.getRequest().getHeader("x-access-token"); if (token != null) { User user = Token.validToken(token, User.class); if (user != null) { ServletActionContext.getRequest().setAttribute("tokenData", user); actionInvocation.invoke(); return null; } } ActionContext context = ActionContext.getContext(); ValueStack stack = context.getValueStack(); stack.set("jsonResult", ResponseTemplate.error(1, "请传输正确token")); return "success"; }
Example #13
Source File: ContentInfoTag.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int doStartTag() throws JspException { int result = super.doStartTag(); try { if (null != this.getMasterObject()) { HttpSession session = this.pageContext.getSession(); UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER); IContentAuthorizationHelper contentAuthHelper = (IContentAuthorizationHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_AUTHORIZATION_HELPER, this.pageContext); boolean isAuthOnEdit = false; if (this.isRecord()) { //PENSARE ALL'OPPORTUNITA'... meno prestante nel caso di oggetto contenuto! String keyValue = (String) super.findValue(this.getKey(), String.class); isAuthOnEdit = contentAuthHelper.isAuthToEdit(currentUser, keyValue, false); } else { isAuthOnEdit = contentAuthHelper.isAuthToEdit(currentUser, (Content) this.getMasterObject()); } if (isAuthOnEdit) { if (null != this.getAuthToEditVar()) { ValueStack stack = this.getStack(); stack.getContext().put(this.getAuthToEditVar(), isAuthOnEdit); stack.setValue("#attr['" + this.getAuthToEditVar() + "']", isAuthOnEdit, false); } result = EVAL_BODY_INCLUDE; } } } catch (Throwable t) { _logger.error("error in doStartTag", t); //ApsSystemUtils.logThrowable(t, this, "doStartTag", "Error on doStartTag"); throw new JspException("Error on doStartTag", t); } return result; }
Example #14
Source File: TracerFactoryTag.java From entando-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Component getBean(ValueStack valueStack, HttpServletRequest req, HttpServletResponse res) { String langCode = this.getActualValue(this.getLang()); ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, req); Lang lang = langManager.getLang(langCode); TracerFactory tracerFactory = new TracerFactory(valueStack, lang); valueStack.getContext().put(this.getVar(), tracerFactory.getAttributeTracer()); return tracerFactory; }
Example #15
Source File: RadioMap.java From entando-core with GNU Lesser General Public License v3.0 | 5 votes |
public RadioMap(ValueStack stack, HttpServletRequest request, HttpServletResponse response, String checked, String var) { super(stack, request, response); if (null != var) { String value = (String) request.getAttribute(var).toString(); this.setVar(value); } if (null != checked) this.setChecked(checked); }
Example #16
Source File: SeoMetatagCatalogTag.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int doEndTag() throws JspException { try { IMetatagCatalog metatagCatalog = (IMetatagCatalog) ApsWebApplicationUtils.getBean(JpseoSystemConstants.SEO_METATAG_CATALOG, pageContext); List<String> keys = new ArrayList<>(metatagCatalog.getCatalog().keySet()); Collections.sort(keys); ValueStack stack = this.getStack(); stack.getContext().put(this.getVar(), keys); stack.setValue("#attr['" + this.getVar() + "']", keys, false); } catch (Throwable t) { logger.error("Error on doStartTag", t); throw new JspException("Error on doStartTag", t); } return super.doEndTag(); }
Example #17
Source File: AbstractObjectInfoTag.java From entando-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int doStartTag() throws JspException { try { String keyValue = (String) super.findValue(this.getKey(), String.class); Object masterObject = this.getMasterObject(keyValue); if (null == masterObject ) { _logger.debug(this.getNullMasterObjectLogMessage(keyValue)); return super.doStartTag(); } String propertyValue = (null != this.getProperty()) ? (String) super.findValue(this.getProperty(), String.class) : null; Object requiredObject = (null != propertyValue) ? this.getPropertyValue(masterObject, propertyValue) : masterObject; if (null == requiredObject) { _logger.debug(this.getNullObjectLogMessage(keyValue, propertyValue)); return super.doStartTag(); } if (null != this.getVar()) { ValueStack stack = this.getStack(); stack.getContext().put(this.getVar(), requiredObject); stack.setValue("#attr['" + this.getVar() + "']", requiredObject, false); } else { this.pageContext.getOut().print(requiredObject); } } catch (Throwable t) { _logger.error("Error on doStartTag", t); throw new JspException("Error on doStartTag", t); } return super.doStartTag(); }
Example #18
Source File: AdminPagerTag.java From entando-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int doStartTag() throws JspException { Object source = this.findValue(this.getSource()); ServletRequest request = this.pageContext.getRequest(); ValueStack stack = this.getStack(); ComponentPagerVO compPagerVo = new ComponentPagerVO(stack); try { AdminPagerTagHelper helper = this.getPagerHelper(); IPagerVO pagerVo = helper.getPagerVO((Collection)source, this.getPagerId(), this.getCount(), this.isAdvanced(), this.getOffset(), request); compPagerVo.initPager(pagerVo); stack.getContext().put(this.getObjectName(), compPagerVo); stack.setValue("#attr['" + this.getObjectName() + "']", compPagerVo, false); } catch (Throwable t) { _logger.error("Error creating the pager", t); //ApsSystemUtils.logThrowable(t, this, "doStartTag"); throw new JspException("Error creating the pager", t); } SubsetIteratorFilter subsetIteratorFilter = new SubsetIteratorFilter(); subsetIteratorFilter.setCount(this.getCount()); subsetIteratorFilter.setDecider(null); subsetIteratorFilter.setSource(source); subsetIteratorFilter.setStart(compPagerVo.getBegin()); subsetIteratorFilter.execute(); this.setSubsetIteratorFilter(subsetIteratorFilter); this.getStack().push(subsetIteratorFilter); if (getId() != null) { pageContext.setAttribute(getId(), subsetIteratorFilter); } return EVAL_BODY_INCLUDE; }
Example #19
Source File: ValueStackAction.java From Project with Apache License 2.0 | 5 votes |
@Override public String execute() throws Exception { ActionContext actionContext = ActionContext.getContext(); ValueStack valueStack = actionContext.getValueStack(); return SUCCESS; }
Example #20
Source File: UserAction.java From Project with Apache License 2.0 | 5 votes |
@Override public String execute() throws Exception { // 1.获取 ActionContext 类的对象 ActionContext actionContext = ActionContext.getContext(); // 2.调用方法获取值栈对象 ValueStack valueStack = actionContext.getValueStack(); // 验证每个 Action 对象只有一个值栈对象 ValueStack valueStack1 = actionContext.getValueStack(); System.out.println(valueStack == valueStack1); return NONE; }
Example #21
Source File: TextParserSample.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 5 votes |
public void safeTextParseUtil(ValueStack stack, TextParseUtil.ParsedValueEvaluator parsedValueEvaluator, Class type) { String input = "1+1"; TextParseUtil.translateVariables(input, stack); TextParseUtil.translateVariables(input, stack, parsedValueEvaluator); TextParseUtil.translateVariables('a', input, stack); TextParseUtil.translateVariables('a', input, stack, type); TextParseUtil.translateVariables(new char[]{'a'}, input, stack, type, parsedValueEvaluator); TextParseUtil.translateVariables(new char[]{'a'}, input, stack, type, parsedValueEvaluator, 0); TextParseUtil.translateVariables('a', input, stack, type, parsedValueEvaluator, 0); }
Example #22
Source File: PlainTextErrorResult.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void execute( ActionInvocation invocation ) throws Exception { HttpServletResponse response = (HttpServletResponse) invocation.getInvocationContext().get( StrutsStatics.HTTP_RESPONSE ); response.setContentType( "text/plain; charset=UTF-8" ); response.setHeader( "Content-Disposition", "inline" ); response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR ); ValueStack stack = ActionContext.getContext().getValueStack(); String finalMessage = parse ? TextParseUtil.translateVariables( message, stack ) : message; finalMessage = formatFinalMessage( finalMessage ); // --------------------------------------------------------------------- // Write final message // --------------------------------------------------------------------- PrintWriter writer = null; try { writer = response.getWriter(); writer.print( finalMessage ); writer.flush(); } finally { if ( writer != null ) { writer.close(); } } }
Example #23
Source File: ApsParametersInterceptor.java From entando-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void setParameters(Object action, ValueStack stack, HttpParameters parameters) { HttpServletRequest request = ServletActionContext.getRequest(); String entandoActionName = ApsRequestParamsUtil.extractEntandoActionName(request); if (null != entandoActionName) { this.createApsActionParam(entandoActionName, request, parameters); } super.setParameters(action, stack, parameters); }
Example #24
Source File: PageTreeTag.java From entando-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int doStartTag() throws JspException { try { IPageActionHelper helper = this.getHelper(this.isOnline()); ITreeNode root = this.getAllowedTreeRootNode(helper); ValueStack stack = this.getStack(); stack.getContext().put(this.getVar(), root); stack.setValue("#attr['" + this.getVar() + "']", root, false); } catch (Throwable t) { _logger.error("error in doStartTag", t); throw new JspException("Error during tag initialization", t); } return super.doStartTag(); }
Example #25
Source File: ComponentPagerVO.java From entando-core with GNU Lesser General Public License v3.0 | 4 votes |
public ComponentPagerVO(ValueStack stack) { super(stack); }
Example #26
Source File: StrutsUtil.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 4 votes |
public StrutsUtil(ValueStack stack, HttpServletRequest request, HttpServletResponse response) { }
Example #27
Source File: VelocityStrutsUtil.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 4 votes |
public VelocityStrutsUtil(VelocityEngine engine, Context ctx, ValueStack stack, HttpServletRequest request, HttpServletResponse response) { super(stack, request, response); }
Example #28
Source File: AnchorTag.java From JavaEE-SSH-Template with MIT License | 4 votes |
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) { return new Anchor(stack, req, res); }
Example #29
Source File: AnchorTag.java From SmartEducation with Apache License 2.0 | 4 votes |
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) { return new Anchor(stack, req, res); }
Example #30
Source File: Hidden.java From entando-core with GNU Lesser General Public License v3.0 | 4 votes |
public Hidden(ValueStack stack, HttpServletRequest request, HttpServletResponse response) { super(stack, request, response); }