示例#1
0
// RetrieveStationJSON handles the example 3 tab.
// http://localhost:9003/buoy/station/42002
func (controller *BuoyController) RetrieveStationJSON() {
	// The call to ParseForm inside of ParseAndValidate is failing. This is a BAD FIX
	params := struct {
		StationID string `form:":stationId" valid:"Required; MinSize(4)" error:"invalid_station_id"`
	}{controller.GetString(":stationId")}

	if controller.ParseAndValidate(&params) == false {
		return
	}

	buoyStation, err := buoyService.FindStation(&controller.Service, params.StationID)
	if err != nil {
		log.CompletedErrorf(err, controller.UserID, "Station", "StationID[%s]", params.StationID)
		controller.ServeError(err)
		return
	}

	controller.Data["json"] = buoyStation
	controller.ServeJson()
}
示例#2
0
// RetrieveStation handles the example 2 tab.
func (controller *BuoyController) RetrieveStation() {
	var params struct {
		StationID string `form:"stationID" valid:"Required; MinSize(4)" error:"invalid_station_id"`
	}

	if controller.ParseAndValidate(&params) == false {
		return
	}

	buoyStation, err := buoyService.FindStation(&controller.Service, params.StationID)
	if err != nil {
		log.CompletedErrorf(err, controller.UserID, "BuoyController.RetrieveStation", "StationID[%s]", params.StationID)
		controller.ServeError(err)
		return
	}

	controller.Data["Station"] = buoyStation
	controller.Layout = ""
	controller.TplNames = "buoy/modal/pv_station-detail.html"
	view, _ := controller.RenderString()

	controller.AjaxResponse(0, "SUCCESS", view)
}