i have a form with two tables one for drivers and another for vehicles and i want to select from vehicles vehicle_plate_no where driver name is like driver's names text input on the form. With bellow example i can be able to return all driver's and vehicle's information but unable to get custom information using form text input values.
Model of vehicles table:
public class vehicles extends Model{
@javax.persistence.Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", updatable = false, nullable = false)
public Long Id;
public String vehicle name;
public String vehicle_plate_no;
public String created_at;
@Column(name="time", insertable=false ,columnDefinition="TIMESTAMP" )
@Temporal(TemporalType.TIMESTAMP)
private Date time;
@ManyToOne(cascade = CascadeType.ALL)
public Drivers driver;
public static Model.Finder<Long, vehicles > findvehicles = new
Finder(Long.class, vehicles.class);
public static List<vehicles> Allvehicles() {
return findvehicles .all();
}
}
Controller of vehicles table:
public class AdminDashboard extends Controller {
public static Result DashboardResult()
{
Form<vehicles> result = form(vehicles.class);
return ok(admin.render(vehicles.Allvehicles(), result));
}
}
scalla tamplete:
@( formList: List[vehicles],form: Form[vehicles]) )
@main_dashboard("Vehicle") {
<form class="" role="form">
<table width="1000" >
<tr>
<td width="500">
<div class="form-group col-sm-6">
<input type="text" class="form-control" id="automplete-1"
name="names" />
</div>
</td>
<td width="500" >
<div class="form-group col-sm-8">
<div class="col-lg-10">
<div class='input-group date'
id='datetimepicker8'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<i class="fa fa-calendar" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
</td>
<td>
<div class="form-group ">
<input type='submit' class="form-control btn btn-danger" value="Find" />
</div>
</td>
</tr>
</table>
</form>
</div>
@for(info <- vehicles.Allvehicles()) {
<p>@info.vehicle_plate_no</p>
<p>@info.driver.drivername</p>
}
......................
}