Search code examples
jspstruts

Struts and passing params with follow tag, how is it working?


I have a jsp page that has code like this:

<script language="JavaScript">
function doOK()
{       
    var form = getForm();       
    if(form.varianceIsZeroOrReroute.value == '<%=ReIMConstants.NO%>')
    {
        if(!confirm("<bean:message key="alert.confirm_resolution_variance_not_zero"/>"))
        {
            return;
        }       
    }

    form.saveAction.value = '<%=PriceReviewListForm.SAVE_ACTION_OK%>';
    form.action = "priceReviewVarianceResolutionSave.do";
    form.submit();
    return true;    
}

and then like this

<tr class="gButtonRow">
            <td colspan="4" align="center" class="gContentSection">
                <html:button property="Back" styleClass="gButton" onclick="back();"><bean:message key="button.back"/></html:button>&nbsp;&nbsp;
                <html:button property="OK" styleClass="gButton" onclick="doOK()">&nbsp;&nbsp;<bean:message key="button.ok"/>&nbsp;&nbsp;</html:button>&nbsp;&nbsp;
                <html:button property="Delete" styleClass="gButton" onclick="deleteRecords();"><bean:message key="button.delete"/></html:button>&nbsp;&nbsp;
                <html:button property="ApplyAll" styleClass="gButton" onclick="doApplyAll();"><bean:message key="button.apply_all"/></html:button>&nbsp;&nbsp;
                <html:button property="Cancel" styleClass="gButton" onclick="doCancel();"><bean:message key="button.cancel"/></html:button>&nbsp;&nbsp;
            </td>
        </tr>
    </table>

So, as you see inside the doOK there is reference to the priceReviewVarianceResolutionSave path. Inside the struts-config.xml the path is described like this:

<action path="/priceReviewVarianceResolutionSave"
        type="org.springframework.web.struts.DelegatingActionProxy"
        name="PriceReviewListForm" scope="session">
        <forward name="failureInvoice"
            path="/price_review_variance_resolution.jsp" />
        <forward name="failureDocument"
            path="/price_review_variance_resolution_dispute.jsp" />
        <forward name="successFull" path="/price_review_list.jsp" />
        <forward name="successMore"
            path="/priceReviewDetailLoad.do" />
        <forward name="successDone" path="/home.do?targetTab=t4" />
        <forward name="successApplyAll"
            path="/priceReviewListLoad.do" />
        <forward name="detailMatch" path="/detailMatchBegin.do" />
        <forward name="unauthorized_access"
            path="/home.do?targetTab=t4" />
    </action>

As I've understood it reads some kind of input from the form and depends on it goes to the specific page. For instance, if value is "successApplyAll" then it goes to "/priceReviewListLoad.do". But problem is that I don't see any mention for "successApplyAll" inside the jsp code. So I don't understand where to look to find the code that pass "successApplyAll" to "priceReviewVarianceResolutionSave" part. For sure I've missed some part or got it wrong. Could you help me and explain where I have to look for this part of code? Thanks!


Solution

  • Forward names are used inside actions to determine what comes next.

    Even grep would have helped you find where that string was used in the code, even assuming complete lack of Struts knowledge. That said: if you're working on a Struts codebase it might make sense to take a step back and at least learn some basics.