Results 1 to 3 of 3

Thread: String Literals??

  1. #1
    Join Date
    Jul 2007
    Posts
    14

    Default String Literals??

    What am I doing wrong with the following: do i need to handle the String literals returned by my service method in some special way?

    I have the service method below called on a transition. Everything works fine unless the service method returns a String (although for example, returning 'success' works). I have another upload Action (where the service does not return a String) working perfectly.

    When I return a String (other than e.g. 'success') or null, or some other object everything works as expected however the app fails to transition to the next view (it remains on the file upload page).

    The fact 'success' works suggests Strings need to handled in some way???

    Service Method

    Code:
    @Service(value = "uploadLetterTemplateService")
    public class UploadLetterTemplateService
    {
    	public String processLetterTemplate(FileUpload file) throws IOException
    	{
    		//validate template
    		
    		//return "success";//works
    		//return null;//works
    		//return new AnotherObject(); //works
    		//return "success_"; fails
    		//return //(new String(file.getData().getBytes())); //fails
    	}
    }
    Code:
    	<view-state id="uploadLetterTemplate" view="uploadLetterTemplate"
    		model="fileUpload">
    		<var name="fileUpload" class="com.jpmorganchase.cam.domain.FileUpload" />
    		<transition to="summaryReport">
    			<evaluate 
    				expression="uploadLetterTemplateService.processLetterTemplate(fileUpload)" />
    		</transition>
    	</view-state>
    Last edited by alanhay; Apr 17th, 2012 at 10:52 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    It depends on the return type. As explained in the reference guide. Returning 'success' means a successful invocation in this case else you can use it to drive a transition (i.e. the returned string is interpreted as the next transition). If you want to use it assign it to a variable.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jul 2007
    Posts
    14

    Default

    Quote Originally Posted by Marten Deinum View Post
    If you want to use it assign it to a variable.
    Although I have omitted the result="x" assignment in my post, that is what I am trying to do. I simply want to return a String and store it.

    The assignment does happen but the view does not transition to the next flow.

    Code:
    <evaluate expression="uploadLetterTemplateService.processLetterTemplate(fileUpload)" result="x.y"/>
    The setter on x is called but there is no transition to the next view.

    I am obviously missing something here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •