Download Play Framework:
https://www.playframework.com/download
Execute:
./activator ( Mac )
| public class MainActivity extends Activity { | |
| ProductDAO dao; | |
| EditText nomeProduto, descricaoProduto; | |
| Button btnCadatrarProduto; | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_main); |
| //Baixe a dependรชncia: compile 'org.immutables:gson:2.1.4' | |
| //Implemente a interface Serializรกvel. Se houver outras classes nos atributos, implemente a interface nelas tambรฉm! | |
| public class User implements Serializable { | |
| private String login; | |
| private String senha; | |
| //Getters and Setters.. | |
| } | |
| //Recebendo uma Lista do servidor (webservice) |
| public class MainActivity extends Activity { | |
| List<String> listaBox; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_main); | |
| listaBox = new ArrayList<String>(); | |
| /** |
| package util; | |
| import ch.qos.logback.core.net.SyslogOutputStream; | |
| import org.apache.commons.io.IOUtils; | |
| import org.apache.http.client.HttpClient; | |
| import org.apache.http.client.methods.HttpPost; | |
| import org.apache.http.entity.StringEntity; | |
| import org.apache.http.impl.client.DefaultHttpClient; | |
| import org.json.simple.JSONObject; | |
| import play.Logger; |
| // Recebo o id da View | |
| public Result update(Long id) { | |
| Form<Local> editForm = localForm.bindFromRequest(); | |
| //Busco o local pelo id (no banco) | |
| Local localFromDb = Local.find.byId(id); | |
| if (editForm.hasErrors()) { | |
| LocalController.flashGlobalError(String.valueOf(editForm.get().getId())); | |
| return badRequest(views.html.localEdit.render(localForm, id)); |
| public Result update(Long id) { | |
| Form<Local> editForm = localForm.bindFromRequest(); | |
| Local localFromForm = Local.find.byId(id); | |
| if (editForm.hasErrors() || editForm.get().getId() == null) { | |
| return badRequest(views.html.localEdit.render(localForm, localFromForm.getMainUser(), id)); | |
| } | |
| Local local = editForm.get(); | |
| Ebean.refresh(local); | |
| return redirect(routes.LocalController.localByUser(localFromForm.getMainUser().getId())); |
| <div class="card"> | |
| <div class="col s12"> | |
| <div class="row"> | |
| <!-- like <form> tag --> | |
| @form(routes.MainUserController.findUserByName(), 'class -> "container") { | |
| <div class="input-field col s8"> | |
| <input type="text" id="name" name="name" required placeholder="Pesquise um cliente" value="@userForm.apply(" name").value" /> | |
| </div> | |
| <div class="col s4"> | |
| <button class="btn waves-effect waves-light" type="submit" |
| public enum LocalType { | |
| PREFEITURA(1), CAMARA(2); | |
| public final int id; | |
| LocalType(int id) { | |
| this.id = id; | |
| } | |
| } |
| <div class="input-field col s6"> | |
| @inputText(userForm("name"), 'id -> "name", '_label -> null) | |
| <label for="name">NOME</label> | |
| </div> |