Alternative Flow in Spring

Asked

Viewed 129 times

2

Faced with the situation: I am on the registration screen of cars, where I can select the brand and type the model. In case I need to register a model that does not have the brand previously registered, I have a link that leads to the trademark registration page. The correct would be at the end of the brand registration, return to the car registration screen, and not be displayed the default screen of brand list.

How to implement this in Spring?

  • 1

    What have you tried?

  • How is your code currently controller? Is there any restriction on the use of additional parameters in query string? (the most common solution is to redirect to the Referer, but this is not reliable)

  • post the code, please

2 answers

1


The smoothest way for the user would be to implement the brand registration screen in a separate View and Controller, and then, when the user is registering the car, you can use a Dialog (jQuery UI type) and display the Brand registration view only, all via ajax. That way the user does not lose what he is doing in the car.

Another possibility is to use Session to save what the guy was writing on the car screen, redirect him to the brand registration, and then return him to the car. But using Session is not very much the concept of Spring MVC, which is something done for Request-Response, so the first option is "more correct".

  • 1

    Thanks for the contribution Renanif, really the user would feel more comfortable operating this way.

1

You can submit a POST or GET variable to the brand registration page. Depending on the value of this variable, you know where to direct when you finish registering brands.

if(request.getParameter("flagOrigem").equals("1")){
return "cadastro/carros";
}else{
return "lista/marcas";
}

the variable "flagOrigem" was sent from the registration page of cars with the value = "1";

But I agree with @Renanlf that the most elegant solution for the user is to use jModal with ajax;

  • This solution works and would be even the simplest to implement. However, I think it is more advisable to use "1" to compare with possible GET values, thus eliminating problems arising from a possible empty GET. Thank you for your contribution!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.