Search code examples
mulemule-studiomule-componentmule-elmule-esb

"Redirecting into HTML page"


I have a flow where I am trying to load a HTML page if successfully login or fails. Flow is working but while doing POST job on browser side it's not redirecting to the loginSuccessful.html or login/loginFailure.html.

<flow name="GetLoginPage">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/login" allowedMethods="GET" doc:name="HTTP"/>
    <parse-template location="login/index.html" doc:name="Parse Template"/>
</flow>
<flow name="Dologin">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/login" allowedMethods="POST" doc:name="HTTP"/>
    <logger message="trying to login!!!!!!!!!!!" level="INFO" doc:name="Logger"/>
    <choice doc:name="Choice">
        <when expression="#[payload.username == &quot;mule&quot; and payload.password == &quot;mule&quot;]">
            <logger message="login successfully!!!!!!!!!!!" level="INFO" doc:name="Logger"/>
            <parse-template location="login/loginSuccessful.html" doc:name="Parse Template"/>
        </when>
        <otherwise>
            <logger message="login failed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" level="INFO" doc:name="Logger"/>
            <parse-template location="login/loginFailure.html" doc:name="Parse Template"/>
        </otherwise>
    </choice>
</flow>

Solution

  • I took the liberty of creating my own payload in JSON and added the payload values from above:

    {
    "name": "mule",
    "password": "mule"
    }
    

    Then, added a data transformer from JSON to Java, then I mildly adjusted your conditional test to eliminate the encoded quotes and replaced them with single quotes:

    payload.username == 'mule' and  payload.password == 'mule'
    

    And the choice router correctly to pick up my test files with the parse template.