Bands: RedirectResolution; How can I redirect to a specific event?

I have a bean action in my strip app. The default handler / method will display a list of data, a list of all objectsMarketResearch

On my JSP, I can click on one to view its detail, it takes me to another JSP with pre-filled forms based on the specific MarketResearchobject that you selected.

I have another method of my bean action that maps to the submit button save, this takes what is in the modified form and saves it. After this happened, I want it to redirect back to the form, and not to the listing action (default handler), is this possible?

My action is as follows:

public class MarketResearchAction extends BaseAction
{

    @SpringBean
    ClientService clientService;
    private static final String VIEW = "/jsp/marketResearch.jsp";
    private Client client;
    private Client clientBeforeChanges;


    public Client getClient()
    {
        return client;
    }

    public void setClient(Client client)
    {
        this.client = client;
    }

    @DefaultHandler
    public Resolution viewAll()
    {
        return new ForwardResolution(VIEW);
    }

    public Resolution viewClientMarketResearch()
    {
        if (client.getSector().equals("Education"))
        {
            return new ForwardResolution("/jsp/marketResearchEducation.jsp");
        } else if (client.getSector().equals("Local Government"))
        {
            return new ForwardResolution("/jsp/marketResearchLocalGovernment.jsp");
        } else if (client.getSector().equals("Housing Association"))
        {
            return new ForwardResolution("/jsp/marketResearchHousing.jsp");
        }
        return new ForwardResolution("/jsp/viewClientMarketResearch.jsp");
    }

    public Resolution save()
    {
        clientBeforeChanges = clientService.getClientById(client.getId());
        clientService.persistClient(client);
        getContext().getMessages().add(new SimpleMessage("{0} updated", client.getName()));
        return new RedirectResolution("/MarketResearch.action").flash(this);
    }

    public Client getClientBeforeChanges()
    {
        return clientBeforeChanges;
    }

    public void setClientBeforeChanges(Client clientBeforeChanges)
    {
        this.clientBeforeChanges = clientBeforeChanges;
    }

    public ClientService getClientService()
    {
        return clientService;
    }

    public void setClientService(ClientService clientService)
    {
        this.clientService = clientService;
    }


}

? - ?

+3
1

. RedirectResolution jsp. , save(), :

return new RedirectResolution("/theJsp.jsp")
    .addParameter("one", one)
    .addParameter("two", two)
    .addParameter("three", three)
    .flash(this);

, , - . MarketResearch , .

<stripes:hidden name="marketResearch"  value="${ActionBean.marketResearch}"/> 

/getter/setter MarketResearchActionBean.

+3

Source: https://habr.com/ru/post/1739019/


All Articles