Announcement Announcement Module
Collapse
No announcement yet.
Set Action and string values Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Set Action and string values

    Is it possible to set a string value in a set action?
    I have a flow and need to pass a parameter to a jsp (parameter name is 'graphdesc' and its value is 'myfrontend', needed for dynamically build the form with serach criteria), so I did this:

    Code:
    <view-state id="enterCriteria" view="users/searchDynamicCriteria">
    	
       <entry-actions>
    	<set attribute="graphdesc" scope="flash" value="myfrontend" />
       </entry-actions>
       <render-actions>
    	<action bean="formAction" method="setupForm" />
       </render-actions>
       <transition on="search" to="displayResults">
    
    ...
    </view-state>
    With this code I get the following stacktrace with an expression evaluation exception:

    Code:
    17:43:21,765 DEBUG DispatcherServlet:492 - Could not complete request
    org.springframework.webflow.engine.ActionExecutionException: Exception thrown executing [AnnotatedAction@4d5575 targetAction = org.springframework.webflow.action.SetAction@88d319, attributes = map[[empty]]] in state 'enterCriteria' of flow 'usersearch-flow' -- action execution attributes were 'map[[empty]]'; nested exception is org.springframework.binding.expression.EvaluationException: Expression [EvaluationAttempt@5585dc expression = myfrontend, target = [RequestControlContextImpl@e4e358 externalContext = [ServletExternalContext@18baf36 requestParameterMap = map['_flowId' -> 'usersearch-flow']], requestScope = map[[empty]], attributes = map[[empty]], flowExecution = [FlowExecutionImpl@1ee04fd flow = 'usersearch-flow', flowSessions = list[[FlowSessionImpl@19c6163 flow = 'usersearch-flow', state = 'enterCriteria', scope = map[[empty]], flashMap = map[[empty]], status = Active]]]], context = [null]] failed - make sure the expression is evaluatable on the target object; nested exception is ognl.NoSuchPropertyException: org.springframework.webflow.engine.impl.RequestControlContextImpl.myfrontend
    Caused by: 
    org.springframework.binding.expression.EvaluationException: Expression [EvaluationAttempt@5585dc expression = myfrontend, target = [RequestControlContextImpl@e4e358 externalContext = [ServletExternalContext@18baf36 requestParameterMap = map['_flowId' -> 'usersearch-flow']], requestScope = map[[empty]], attributes = map[[empty]], flowExecution = [FlowExecutionImpl@1ee04fd flow = 'usersearch-flow', flowSessions = list[[FlowSessionImpl@19c6163 flow = 'usersearch-flow', state = 'enterCriteria', scope = map[[empty]], flashMap = map[[empty]], status = Active]]]], context = [null]] failed - make sure the expression is evaluatable on the target object; nested exception is ognl.NoSuchPropertyException: org.springframework.webflow.engine.impl.RequestControlContextImpl.myfrontend
    Caused by: 
    ognl.NoSuchPropertyException: org.springframework.webflow.engine.impl.RequestControlContextImpl.myfrontend
    	at ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:122)
    	at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)
    
    ...

    If I use numeric or boolean values, everything goes fine.

    What's wrong with my code?

  • #2
    hi...

    how you use the parameter in jsp.. ? i'd rather confuse about what you mean about parameter...
    when you need a value that used in jsp, you can set the an attribute in a request, flash, or flow scope isn't it ?
    as example if use flow scope we can do like this :
    Code:
    class SomeAction extends FormAction {
      ...
    public Event prepareDataForJsp(RequestContext context) {
    ...
      context.getFlowScope().put("attributeName", attributeValue);
    ...
    }
    ...
    }
    so in jsp you can access attribute by its name like :
    Code:
    attributeValue is :  ${attributeName}
    regards
    pancara

    Comment


    • #3
      I call directly the parameter from inside the jsp:

      Code:
      <%@ include file="/WEB-INF/jspf/pageheader.jspf"%>
      
      ...
      <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
      
      <%@ taglib prefix="h" tagdir="/WEB-INF/tags" %>
      
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      ...
      </head>
      <body>
      ...
      
      <div id="view"><!-- View: the VIEW part of MVC --> 
      
      <div class="content-title">Ricerca utente</div>
      <form:form  commandName="searchCriteria" id="userData">
        <fieldset><legend>Dati utente</legend>
      		<h:formBuilder owner="searchCriteria" graphdesc="${graphdesc}"/>
      	</fieldset>
      	<input type="hidden" name="_flowExecutionKey"
      		value="${flowExecutionKey}" />
      	<div class="button"><input id="search" type="submit"
      		name="_eventId_search" value="Ricerca" /> <input id="reset"
      		type="reset" value="Annulla" /></div>
      </form:form>
      </div>
      <!-- End of View -->
      I use a my tag library and pass this parameter to her.

      If I have numeric or boolean values for parameter 'graphdesc', everything goes fine, I can pass the value to my tag library. The problem arises if I use a string value. I would like to use the default Spring Form Action, without extending it.
      The scope I'm using is 'flash'

      Comment


      • #4
        I found the answers after several tries.
        The problem is that WebFlow try to evaluate the expression. In case of numbers or booleans you can use directly the value itself, and it will be interpreted correctly, but in case of strings, webflow considers them expressions to evaluate. The correct way is to use the following expression:

        ${'string value'}

        Now my code works fine without extending FormAction:

        Code:
        	
        <view-state id="enterCriteria" view="users/searchDynamicCriteria">
        	
           <entry-actions>
        	<set attribute="graphdesc" scope="flash" value="${'mygraphic'}" />
           </entry-actions>
           <render-actions>
        
        ...
        
        </view-state>
        And in my jsp I can access directly to graphdesc parameter, getting the correct value mygraphic:


        Code:
        ...
        
        <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
        
        <%@ taglib prefix="h" tagdir="/WEB-INF/tags" %>
        
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        ...
        </head>
        <body>
        <!--  Container -->
        <div id="container">
        
        <div id="header"><!-- Header  -->
        ...
        <div id="view"><!-- View: the VIEW part of MVC --> 
        
        <div class="content-title">Ricerca utente</div>
        <form:form  commandName="searchCriteria" id="userData">
          <fieldset><legend>Dati utente</legend>
        		<h:formBuilder owner="searchCriteria" graphdesc="${graphdesc}"/>
        	</fieldset>
        	<input type="hidden" name="_flowExecutionKey"
        		value="${flowExecutionKey}" />
        	<div class="button"><input id="search" type="submit"
        		name="_eventId_search" value="Ricerca" /> <input id="reset"
        		type="reset" value="Annulla" /></div>
        </form:form>
        </div>
        <!-- End of View -->
        Thank you for your attention.

        Comment


        • #5
          Good one my friend!
          I also had the same problem and I will try your solution out.
          Just for the record, how did you figure it out? Are the some docs or reference manuals that you can point me to.

          Thanks
          Kris

          Comment


          • #6
            I saw that the message was
            Code:
            org.springframework.binding.expression.EvaluationException: Expression [EvaluationAttempt@5585dc expression = myfrontend...
            This could mean only that it tried to evaluate the string, and not simply read its value, as if the string was inside braces (${...}). Sometimes double quotes mean that the argument inside must be evaluated, whilst the same argument inside single quotes must be read 'as is' (you have this in Perl, PHP, and, I guess, in regular expressions). And so i simply did a try.. and I was luck.

            Comment


            • #7
              Anyway,
              thanks again. This luck of yours saved me quite some time.

              Regards
              Kris

              Comment


              • #8
                What is the difference between &lt;webflow:flow&gt; syntax and &lt;flow&gt;

                Hi ,
                I am planning to use swf 2.0 with spring 2.5.x
                I observed two different syntaxes for webflow xml defintion. one is
                <flow .....> and other is <webflow:flow ...>
                Which is good ? what is the difference ?

                Regards
                Diana

                Comment

                Working...
                X