Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
553 views
in Technique[技术] by (71.8m points)

java - Printing log from flow.xml

I am working on a web application with spring web flow. While I am working on a flow.xml file I have get a decision state on it like this -

<decision-state id="checkPermissin">    
    <if test="requestParameters.canApprove" then="approve" else="warning" />
</decision-state>  

When a request comes to the flow.xml then it get the request parameter canApprove from it and test whether it is true or false. Then it goes to the either of approve or warning state.

My question is - can I log/print the status of canApprove from the flow.xml file?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can add an on-exit tag to the end of the 'decision-state' and call any service methods, spring beans, or static methods on the classpath.

Try this (untested):

<decision-state id="checkPermissin">    
    <if test="requestParameters.canApprove" then="approve" else="warning" />
   <on-exit>
        <evaluate expression="T(org.apache.log4j.Logger).getLogger('someLogger').info(requestParameters.canApprove)"/>
   </on-exit>
</decision-state>

The above solution is more of a hack to fulfill what you are asking for. The "proper" way to log this is to extend a FlowExecutionListenerAdapter and to listen for your current flow + decision-state id "checkPermissin" then log whatever you desire about that flow but it would involve more setup/coding outside the flow.xml file. (see: Catch "dead" session in Spring webflow: the example is for catching exceptions but can easily be adapted for logging anything in a flow)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...