struts1 icon indicating copy to clipboard operation
struts1 copied to clipboard

html:cancel taglib not working in case of MultipartRequestWrapper

Open nrmnrm opened this issue 1 year ago • 4 comments

If I cancel an action using taglib html:cancel on a jsp page it is not propagated to the action if coming from a multipart request, for standard requests its fine (see the two sceenshots from debug mode attached)

working

not_working

nrmnrm avatar Apr 25 '24 13:04 nrmnrm

HI Stefan,

can I help you in any ways to tackle that?

nrmnrm avatar May 14 '24 11:05 nrmnrm

Hi @nrmnrm,

sorry for the long break. I don't have much time at the moment. Maybe you can find a solution and I can have a look at it and release it.

Greetings Stefan

ste-gr avatar May 15 '24 00:05 ste-gr

Took me some hours, but I have found it :) Please check AbstractPopulateActionForm.java and change order in execute_ method, cancel needs to be executed last, as it requires population first to work:

protected boolean execute_(ActionContext actionCtx) throws Exception {

    ActionConfig actionConfig = actionCtx.getActionConfig();
    ActionForm actionForm = actionCtx.getActionForm();

   

    // Is there a form bean for this request?
    if (actionForm == null) {
        return (false);
    }

    // Reset the form bean only if configured so
    if (isReset(actionCtx, actionConfig)) {
        log.debug("Reseting form bean '{}'",  actionConfig.getName());
        reset(actionCtx, actionConfig, actionForm);
    }

    // Populate the form bean only if configured so
    if (isPopulate(actionCtx, actionConfig)) {
        log.debug("Populating form bean '{}'", actionConfig.getName());
        populate(actionCtx, actionConfig, actionForm);
    }

// Always handle cancel last, as it needs populate first
    handleCancel(actionCtx, actionConfig, actionForm);
	
    return CONTINUE_PROCESSING;
}

Not sure when and why changing of the order was introduced but it definitely breaks html:cancel on mulitpart requests: I have rebuild with that change and it works fine for me now.

Best regards!

nrmnrm avatar Jun 13 '24 11:06 nrmnrm

I think this commit broke it "STR-286 and STR-1116: ActionForm populate and reset strategy"

nrmnrm avatar Jun 14 '24 08:06 nrmnrm