在我的GUI应用程序中,我有两个视图:playlistView.fxml和videoView.fxml.每个人都有自己的控制器.我希望playListView成为videoView布局的一部分,所以我使用:
<fx:include fx:id="idPlayListAnchorPane" source="playListView.fxml" />
Run Code Online (Sandbox Code Playgroud)
包含文件.工作正常,播放列表显示为videoView布局的一部分.
然后我将idPlayListAnchorPane FXML变量注入VideoViewController,如下所示:
@FXML
private AnchorPane idPlayListAnchorPane;
Run Code Online (Sandbox Code Playgroud)
也工作.例如,我可以禁用idPlayListAnchorPane在playListView从VideoViewController有:
idPlayListAnchorPane.setDisable(true);
Run Code Online (Sandbox Code Playgroud)
要获取playListViewController,我使用:
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/designer/views/video/playListView.fxml"));
PlayListViewController playListViewController = new PlayListViewController();
loader.setController(playListViewController);
try {
AnchorPane playListView = (AnchorPane) loader.load();
} catch (IOException e) {
};
Run Code Online (Sandbox Code Playgroud)
然后我可以打电话给例如:
playListViewController.init();
Run Code Online (Sandbox Code Playgroud)
来自videoViewController.
但init()方法在playListView ListView中创建了一些测试值(作为一个单独的应用程序进行测试,并且可以正常工作).但是,这些测试值现在不会显示在ListView中.几个小时后的简单问题是:为什么不呢?
我正在尝试从表单上传图像并将其存储在我的laravelproject中.我要存储这些图片的文件夹是calles battlePics,我在资产级别创建了这个文件夹.实际问题是$ filename在此函数后仍为空.这是我的控制器:
if (Input::hasFile('file')) {
$file = input::get('file');
$string = str_random(40);
$filename = hash("md5", $string) . $file->getClientOriginalName();
$file->move('battlePics', $filename);
$battle->picture = $filename;
}
$battle->save();
Run Code Online (Sandbox Code Playgroud)
我使用md5哈希创建不同的文件名,以避免在上传具有相同名称的图像时出错.以下是我的表格视图:
<form id="battleForm" class="battleForm" action="" method="post" role="form">
<input type="hidden" name="userID" value="{{Auth::id()}}">
<div class="form-group">
<label for="title">Title of the battle?</label><br>
<input type="text" id="title" name="title" placeholder=""><br>
</div>
<div class="form-group">
<label for="points">Points to be earned</label><br>
<input type="text" id="points" name="points" placeholder=""><br>
</div>
<div class="form-group date">
<label for="startdate">Startdate</label><br>
<input type="date" id="startdate" name="startdate" placeholder=""><br>
</div>
<div class="form-group date">
<label for="enddate">Enddate</label><br>
<input type="date" …Run Code Online (Sandbox Code Playgroud) 我有一个javafx应用程序,我有一个主要的设置我的舞台并启动应用程序.我也有一个控制器类:
public class Controller
{
@FXML Button button;
public void test(){
button.setText("Button");
}
}
Run Code Online (Sandbox Code Playgroud)
我如何在启动时运行测试方法.我知道我可以在主类中创建一个实例......
public class Main extends Application{
public void start(Stage primaryStage) throws Exception {
...
public static void main (String[] args){
launch (Main.class);
Controller cont = Controller();
cont.test();
}
}
Run Code Online (Sandbox Code Playgroud)
这会奏效.然而,这对我来说并不理想.我想知道是否可以直接从控制器类运行该方法,如果没有更好的方法来处理它?谢谢
我想让user_id奇怪的所有用户都喜欢(1,3,5,7,9,11 ......)有没有简单的选择呢?
@fed = Users.all
我正在尝试将用户从控制器上的方法重定向到另一个视图但无论我做什么都无法使其工作.我究竟做错了什么?这是我的代码:
public ActionResult SubmitReport(string JsonStringSend)
{
dynamic JSend = JObject.Parse(JsonStringSend);
var schema = JsonSchema4.FromType<ReportItem>();
var schemaData = schema.ToJson();
var errors = schema.Validate(JSend.JsonString);
schema = JsonSchema4.FromJson(schemaData);
//Check for errors and show them if they exist
if (errors.Count > 0)
{
//JSchema schema = JSchema.Parse(schema);
foreach (var error in errors)
Console.WriteLine(error.Path + ": " + error.Kind);
//JObject JsonString = JObject.Parse(JsonObj.JsonString.ToString());
//JObject JsonStringSent = JObject.Parse(JsonStringSend);
}
else
{
return Redirect("/Admin/Reporting/ReportManagement");
}
return View();
}
Run Code Online (Sandbox Code Playgroud)
它永远不会重定向.我甚至试过这些:
Response.Redirect(Url.Action("/ReportManagement"));
RedirectToRoute(new { contoller = "ReportManagement", action = …Run Code Online (Sandbox Code Playgroud) 我正试图让我的apicontroller工作.但不知怎的,我不能回来Json().
这是编译器的错误消息:
错误CS0029无法将类型'System.Web.Http.Results.JsonResult <>'隐式转换为'System.Web.Mvc.JsonResult'Opten.Polyglott.Web D:\ Development\git\Opten.Polyglott\src\Opten.Polyglott名.web \控制器\ NewsletterApiController.cs
我无法解释为什么它无法转换Json()为ActionResult偶数的Json()继承ActionResult.
这是我的控制器:
using MailChimp;
using MailChimp.Helper;
using Opten.Polyglott.Web.Models;
using Opten.Umbraco.Common.Extensions;
using System.Configuration;
using System.Web.Mvc;
using Umbraco.Core.Logging;
using Umbraco.Web.WebApi;
namespace Opten.Polyglott.Web.Controllers
{
public class NewsletterApiController : UmbracoApiController
{
public ActionResult Subscribe(Newsletter newsletter)
{
bool isSuccessful = false;
if (ModelState.IsValid)
{
isSuccessful = SubscribeEmail(newsletter.Email);
}
return Json(new { isSuccess = isSuccessful });
}
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
当我在我的控制器中编写以下代码以使其与OData分页兼容时,我遇到此警告:
这种方法已经过时; 使用System.Web.Http.OData.Extensions或System.Web.OData.Extensions命名空间中的ODataProperties().NextLink属性.
return new PageResult<UserInfo>(
results as IEnumerable<UserInfo>,
Request.GetNextPageLink(),
Request.GetInlineCount());
Run Code Online (Sandbox Code Playgroud) 至于标题,我花了大约两个小时的时间来寻找有效的答案,并反复阅读了官方文档,但考虑到我对框架相对较新,则没有任何进一步的改进。在寻找一种在控制器之间共享一些代码的正确方法时,我产生了疑问,我偶然发现了服务提供商,因此:
MyCustomServiceProvider;providers和aliases数组中app.php;最后,我创建了一个自定义帮助程序类,并将其注册为:
class MyCustomServiceProvider extends ServiceProvider
{
public function boot()
{
//
}
public function register()
{
$this->app->bind('App\Helpers\Commander', function(){
return new Commander();
});
}
}
Run Code Online (Sandbox Code Playgroud)但是到目前为止,如果我在控制器中使用该自定义类,则必须通过以下use语句向其添加路径:
use App\Helpers\Commander;
Run Code Online (Sandbox Code Playgroud)
否则,我得到一个很好的类,未发现异常,显然我的控制器没有执行他的工作。
我怀疑在服务提供商中有些事情对我不利!:-)
我显然错过了一些东西,但我不知道是什么......
愚蠢的是,有多少小事让你变得疯狂而不是复杂的......
这是控制器的代码:
@RequestMapping(value = "/getClienteNomeCognome", method = RequestMethod.GET)
public ResponseEntity<List<Object>> getClienteNomeCognome(@RequestParam("nomeCliente") String nomeCliente,
@RequestParam("cognomeCliente") String cognomeCliente) {
List<Object> listaRisultati = new ArrayList<Object>();
try {
listaRisultati = serviziDocumentaleService.getClienteNomeCognome(nomeCliente, cognomeCliente);
} catch (Exception e) {
LOGGER.warn(String.format("Errore inatteso sulla chiamata del servizio: [%s]", e.toString()));
}
LOGGER.info(String.format("Avvio ricerca cliente con nome: %s, cognome: %s)", nomeCliente, cognomeCliente));
return new ResponseEntity<List<Object>>(listaRisultati, HttpStatus.OK);
}
Run Code Online (Sandbox Code Playgroud)
这是getClienteNomeCognome:
public List<Object> getClienteNomeCognome(String nome, String cognome) throws Exception {
try {
final RestTemplate restTemplate = new RestTemplate();
final String url = …Run Code Online (Sandbox Code Playgroud) 在Symfony2中,至少在Symfony 2.4之前,可以在树枝中呈现这样的控制器
{% render(controller("MyBundle:Default:method", { 'call' : 'action' })) %}
Run Code Online (Sandbox Code Playgroud)
使用Symfony 3,会抛出异常
Unexpected "render" tag (expecting closing tag for the "block" tag defined
Run Code Online (Sandbox Code Playgroud) controller ×10
c# ×2
php ×2
actionresult ×1
asp.net-mvc ×1
fxml ×1
image ×1
java ×1
javafx ×1
javafx-8 ×1
json ×1
laravel ×1
laravel-5.2 ×1
mysql ×1
odata ×1
redirect ×1
render ×1
response ×1
resttemplate ×1
ruby ×1
symfony ×1
twig ×1
upload ×1