我在一个巨大的集合(超过10k对象)上有一个很大的Symfony 2表单.由于简单的原因,我无法显示数千个对象的形式.我正在显示大约300个物体的形式.
我发现无法将集合过滤到表单中,因此执行以下操作:
$bigSetOfObjects = array(
'myObject' => $this
->getDoctrine()
->getRepository('MyObject')
->findBy(... )
);
$form = $this->createForm(new MyObjectForm(), $bigSetOfObjects);
// And a little further
if ($this->getRequest()->getMethod() == 'POST') {
$form->bindRequest($this->getRequest());
$this->getDoctrine()->getEntityManager()->flush();
}
Run Code Online (Sandbox Code Playgroud)
一切都很好.表单显示正确的值,更新也正常.数据已正确保存到数据库中.问题是Doctrine正在为每个对象执行一个更新语句,这意味着整个页面大约有300个SQL语句,导致性能问题.
我不明白的是,我只更新了表格中的几个值,而不是全部.那么为什么Doctrine无法检测更新的对象,因此只更新数据库中的那些对象?
有什么我做错了吗?我可能已经忘记了?
出于安全原因,有时需要通过IP阻止用户.就我而言,我想在(SQL)数据库中管理IP黑名单.我想我可以根据Action Composition处理过滤器部分,但为此我需要用户的IP.
那么,我怎样才能获得用户的IP?
PS:应用程序在nginx代理后面运行.
题
Play 2.1 RC2有自制软件吗?我一直在尝试搜索谷歌,但没有运气.谢谢!
更新1
我想我明白了.我找到了RC1的公式,并对其进行了修改,为RC2创建了一个公式.我正在测试它.这是我在本地机器上创建的play.rb的内容.
# Recipe for play-2.1-RC2
require 'formula'
class Play < Formula
homepage 'http://www.playframework.org/'
url 'http://download.playframework.org/releases/play-2.1-RC2.zip'
sha1 'cd25571250b753cec81e916059025465e541637d'
version '2.1-RC2'
def install
rm Dir['*.bat'] # remove windows' bat files
libexec.install Dir['*']
inreplace libexec+"play" do |s|
s.gsub! "$dir/", "$dir/../libexec/"
s.gsub! "dir=`dirname $PRG`", "dir=`dirname $0` && dir=$dir/`dirname $PRG`"
end
bin.install_symlink libexec+'play'
end
end
Run Code Online (Sandbox Code Playgroud)
更新2
我已经为上面的文件创建了一个公开要点.所以,这是您可以用来安装Play 2.1 RC2的最终命令:
brew install https://gist.github.com/raw/4579402/play.rb
Run Code Online (Sandbox Code Playgroud)
您可能需要取消以前安装的Play版本的链接,使用:
brew unlink play
Run Code Online (Sandbox Code Playgroud)
更新3
截至今天(2013年2月3日),Faruk建议的brew命令仍在安装RC2,我想要RC4.所以这是安装Play 2.1 RC4的命令.
brew install https://gist.github.com/raw/4705322/play.rb
Run Code Online (Sandbox Code Playgroud) 我无法理解为什么我不能引用scala枚举类型.
问题是有时我可以引用枚举:
enum(UserStatus)
Run Code Online (Sandbox Code Playgroud)
有时它抱怨无法找到枚举
not found: type UserStatus
Run Code Online (Sandbox Code Playgroud)
为什么我有时不能引用Enumeration类?
枚举的生成源似乎没问题,并且它与我生活在同一个地方的另一个枚举很有效,相同的用法......
有什么建议?
生成的枚举源是:
public final class models.UserStatus extends java.lang.Object{
public static final scala.Enumeration$Value Busy();
public static final scala.Enumeration$Value Free();
public static final scala.Enumeration$ValueSet$ ValueSet();
public static final scala.Enumeration$Value withName(java.lang.String);
public static final scala.Enumeration$Value apply(int);
public static final int maxId();
public static final scala.Enumeration$ValueSet values();
public static final java.lang.String toString();
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试为play framework 2.0实现一个枚举映射器
def enumFormat[E <: Enumeration](enum: E): Formatter[E#Value] = new Formatter[E#Value] {
def bind(key: String, data: Map[String, String]) = …
Run Code Online (Sandbox Code Playgroud) 我有一个模型列表(列表项),我在模板中循环:
@for(item <- items) {
// ...
}
Run Code Online (Sandbox Code Playgroud)
我想得到item
in 的键/索引位置有items
两个原因:
Item n° @key
if (@key % 2)
)如果使用List而不是Map,我如何获得键/索引?
谢谢你的帮助
这是我的路线文件中的一行:
GET /detail controllers.Message.detail(type: String, text: String, page: Integer ?= 0)
Run Code Online (Sandbox Code Playgroud)
当我尝试加载页面时,它突出显示了这一行,并声明"标识符已预期,但'类型'已找到.".现在,如果我将参数从更改type: String
为newType: String
,则页面正常加载.
这个词有type
什么问题?路由文件中是否有保留字?
将用户在jQuery Handsontable中输入的数据上传回Server以保存到数据库中的最佳方法是什么?
onChange
使用AJAX保存输入数据的现有回调似乎非常冗长,尤其是当用户在现有数据行上方插入新数据行时.在使用Handsontable或jQuery完成编辑后,寻找上传输入数据的功能
下面是使用jQuery循环输入数据并以JSON格式转储到文本框然后提交给服务器的完整代码.这个过程看起来很难看.寻找更清洁的方式..
$('#btnGo').click(function() {
var rowList = new Array();
$("table tr").each(function() {
var colList = new Array();
$("td", this).each(function() {
colList.push($(this).text());
});
rowList.push(colList);
});
$('#simple').val(JSON.stringify(rowList));
console.log(rowList);
});?
Run Code Online (Sandbox Code Playgroud) 我有一个表单,其中有一个绑定到属性的输入文本字段:
@helper.inputText(myForm("username"))
Run Code Online (Sandbox Code Playgroud)
但我希望避免输入字段的帮助器.我想直接将输入文本字段与模型中的属性绑定,如:
<input type="text" value=@myForm("username")>
Run Code Online (Sandbox Code Playgroud)
有关如何做到这一点的任何指示?
我为Play编写了一个简单的测试类!2.0:
public class TestLogin {
@Test
public void test() {
running(testServer(3333, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() {
@Override
public void invoke(TestBrowser browser) {
browser.goTo("http://localhost:3333");
assertThat(browser.$("section h1").first().getText()).isEqualTo("Login");
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
在Play v1中,您可以执行以下命令:
play test
Run Code Online (Sandbox Code Playgroud)
你可以转到http://localhost:9000/@tests
.但是现在在Play 2.0中这不起作用而且没有记录?我只是想开始我的Selenium测试,手动(每个测试用例/方法)自动化(一堆测试用例).
如何在Play2.0中实现这一目标?
BTW:运行命令播放测试在终端输出以下内容:
[warn] 1 warning
[info] No tests to run for test:test
Run Code Online (Sandbox Code Playgroud) 在我的项目中,我使用框架作为Symfony2.我想写一个php函数,如果条件失败,它会重定向到默认页面.所以我的功能是这样的.
public function validate($value){
if($value==null){
return $this->redirect(
$this->generateUrl('home_page', array("message"=>""))
);
}
}
Run Code Online (Sandbox Code Playgroud)
我把这个函数称为这样.
$this->validate($value);
Run Code Online (Sandbox Code Playgroud)
问题是重定向不会发生.
拜托,伙计们,帮助我.我不知道它为什么不重定向.谢谢
scala ×2
symfony ×2
doctrine-orm ×1
handsontable ×1
homebrew ×1
java ×1
javascript ×1
jquery ×1
nginx ×1
php ×1
redirect ×1
spreadsheet ×1
this ×1