Announcement Announcement Module
Collapse
No announcement yet.
I can't find a way to set parameters with workflow. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • I can't find a way to set parameters with workflow.

    I can't find a way to set render parameters with workflow in a way that is portlet agnostic. As you can see in the code below I was able to pass request parameters to valuelist by passing the getParameters from the originating event. One of the request parameters I need to pass through to the render phase and the only way I was able to do it was through the portletresponse. Is there something I am missing?

    Code:
    	public Event populateTopicValueList(RequestContext context) throws Exception {
    	
    		ValueListInfo topics = new ValueListInfo(ValueListRequestUtil.getRequestParameterMap(context.getOriginatingEvent().getParameters(),TOPIC_SELECTION_VL_NAME));
    		
    
    		topics.getFilters().putAll(profile.getProperties());
    		
    		Object topicIdObj2 = context.getOriginatingEvent().getParameter(SELECTED_TOPIC_ID);
    		if (topicIdObj2 instanceof String[]) {
    			topicIdObj2 = ((String[])topicIdObj2)[0];
    		} 
    
         // this code below just wants to set a render parameter. Should be portlet agnostic but I couldn't find a way.
    
    		PortletResponse portletResponse = ((PortletRequestEvent)context.getOriginatingEvent()).getResponse();
    
    		if (portletResponse instanceof ActionResponse) {
    			if (StringUtils.isNotEmpty((String) topicIdObj2)) {
    				topics.getFilters().put(TOPIC_ID_FILTER,
    						Integer.valueOf((String) topicIdObj2));
    				String[] renderTopicId = new String[1];
    				renderTopicId[0] = (String) topicIdObj2;
    				((ActionResponse) portletResponse).setRenderParameter(
    						SELECTED_TOPIC_ID, renderTopicId);
    			} else {
    				PortletRequest portletRequest = ((PortletRequestEvent) context
    						.getOriginatingEvent()).getRequest();
    				Map paramMap = portletRequest.getParameterMap();
    				Map newParamMap = new HashMap(paramMap);
    				newParamMap.remove(SELECTED_TOPIC_ID);
    				((ActionResponse) portletResponse)
    						.setRenderParameters(newParamMap);
    			}
    		}
    
    		ValueList valueList = valueListHelper.getValueListHandler().getValueList(TOPIC_SELECTION_VL, topics); 
    
    		context.getRequestScope().setAttribute(TOPIC_SELECTION_VL, valueList);
    		
    		return success();
    	}

  • #2
    Forget about this..

    Forget about this.. parameters appear to pass through fine. For some reason at sometime I thought they didn't but it seems everything works now for some reason.

    Comment


    • #3
      Acutally I still have problems....

      What I have is a situation where a request comes in and an action runs. In the action

      context.getOriginatingEvent().getParameters()

      contains the submitted parameters...

      However context.getOriginatingEvent() appears to contain a collection called renderParameters which does not contain the original request parameters. Thus on the resulting page

      pageContext.getRequest().getParameterValues(name);

      does not return the submitted parameter.


      Is this a bug or is there something I am doing wrong?

      Comment


      • #4
        My guess would be that this is a bug in paramater handling outside of the web flow system, probably in the Porlet engine. I would try to debug step through the code to find out where these strange parameters are coming from.

        Erwin

        Comment


        • #5
          The problem is not strange parameters...

          The problem is not strange parameters... The problem is parameters are getting lost....

          Comment


          • #6
            render parameter passed forward

            Not sure if I am following exactly the problem, but it is true that render parameters must be explicitly passed forward from the action phase to the render phase. This is done using the setRenderParameter methods in the ActionResponse. If there are no calls to setRenderParameter(s), then there will not be any parameters in the render phase.

            Comment


            • #7
              Try getSourceEvent() instead of originatingEvent.

              I had this problem as well.

              In the end, I end up manually copying the parameters from my action into my success/error event.

              Comment

              Working...
              X