Java Code Examples for com.opensymphony.xwork2.util.ValueStack#setValue()

The following examples show how to use com.opensymphony.xwork2.util.ValueStack#setValue() . 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: ActivityStreamTag.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 2
Source File: ActivityStreamLastUpdateTag.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 3
Source File: ShortcutListTag.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 4
Source File: HookPointTag.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 5
Source File: PluginsSubMenuTag.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 6
Source File: UserShortcutsConfigTag.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 7
Source File: CmsAdminPagerTag.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 8
Source File: ContentStepTag.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 9
Source File: ContentStepsTag.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 10
Source File: PageTreeTag.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 11
Source File: AdminPagerTag.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 12
Source File: AbstractObjectInfoTag.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 13
Source File: ContentInfoTag.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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: SeoMetatagCatalogTag.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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();
}