Olá. Estou tentando fazer a captura de valores num combobox. Mas só tenho conseguido null. O que há?
@*
* This template takes a single argument, a String containing a
* message to display.
*@
@(message: String)
@*
* Call the `main` template with two arguments. The first
* argument is a `String` with the title of the page, the second
* argument is an `Html` object containing the body of the page.
*@
@main("Welcome to Play") {
<h1>Bem-vindo a SEMOB</h1>
<h3>Consulte a situação de seu veículo</h3>
<form name= "marcas" id= "marcas" method = "POST">
<label for="select">Marca</label>
<select id ="select">
<option value = "">Escolha a Marca</option>
<option value="fiat">Fiat</option>
<option value="WV">Volkswagen</option>
<option value="GM">Chevrolet</option>
<input type="submit" value="submit">
</select>
</form>
}
package controllers;
import javax.inject.Inject;
import play.data.DynamicForm;
import play.data.FormFactory;
import play.mvc.*;
import views.html.*;
public class DetranController extends Controller{
@Inject
private FormFactory forms;
/**
* home page
* @return
*/
public Result index() {
return ok(index.render("sifu"));
}
public Result consultar () {
DynamicForm dynamicForm = this.forms.form().bindFromRequest();
String marca = dynamicForm.get("select");
return ok("marca recebida: " + marca);
}
}
GET / controllers.DetranController.index
POST / controllers.DetranController.consultar
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)