我正在寻找有关如何使用GWT 2.1 Editor框架的一些文档或示例.谷歌的文档是呃,有点缺乏.
从可用的有限文档中,我已经能够理解编辑器(理论上)将允许您更轻松地将GUI元素绑定到数据模型.这将缓解将数据复制到TextArea/ListBox/CheckBox,然后将用户的更改复制回底层模型(最终是数据库)的常见任务.
如果确实能够实现这一目标,那将非常受欢迎.就目前而言,我对如何实施其中任何一个都感到很头疼.任何指向文档或示例的指针都将受到高度赞赏.
我遇到了Hibernate/JPA配置问题,这会阻止我的JPA注释实体被自动注册:
java.lang.IllegalArgumentException: Unknown entity: com.example.crm.server.model.Language
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:671)
at com.example.crm.server.model.Language.persist(Language.java:64)
at com.example.crm.server.LanguageTest.testPersistAndRemove(LanguageTest.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Run Code Online (Sandbox Code Playgroud)
在我的实体课中,我有:
@Entity
@Table(name="Languages")
public class Language implements Serializable
{
@Id
private Long id;
private String name;
// etc...
}
Run Code Online (Sandbox Code Playgroud)
在MySQL中,Languages表看起来像:
+-------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+
| Language_ID | int(11) | NO | PRI | NULL | |
| Name | char(18) | YES | | NULL | |
+-------------+----------+------+-----+---------+-------+
2 rows in …Run Code Online (Sandbox Code Playgroud) 我注意到,当用户第一次访问我的网站时,Wicket生成的URL包含一个jsessionid,而不是依赖于cookie来获取会话信息.
cookie确实成功设置,如果用户只是重新加载页面,jsessionid则不再附加到URL.你可以在这里测试一下:pixlshare.com.将鼠标悬停在任何图片链接上都会显示带有jsessionid; 重新加载页面,jsessionids将被删除.
根据以前的Wicket SEO页面的经验,我知道如何删除jsessionid它以将其隐藏起来,但是对于普通用户使用这种技术似乎是一种黑客攻击.它也将破坏网站,让那些偏执狂的人足以让cookie被禁用.
这是在最近从Glassfish转移到Tomcat之后发生的,尽管我不能肯定地说这是原因.另外,我在Tomcat面前使用Apache的mod_proxy.
在我使用自己的队列之前NSMutableArray,我想知道是否有更多可用的标准.我没有在Apple文档中看到任何内容,但如果没有人们使用的某个地方没有Queue实现,我会感到惊讶.Java破坏了我!
是否可以使用CGPDFDocument或以其他方式访问PDF文档中的"内部"链接?我正在构建一个简单的阅读器应用程序,并希望以PDF格式提供我的内容,但如果我不能支持文档中的页面之间的链接,这可能不会起作用.
这个问题类似,但没有解决如何支持超链接的问题.
我正在使用GWT 2.1的CellBrowser和自定义TreeViewModel.TreeViewModel又使用a AsyncDataProvider来动态获取数据.这一切都很好用 - 当用户点击节点时,我的AsyncDataProvider通过RPC获取结果,并且CellBrowser尽职尽责地显示它们.
我觉得无法解决这个问题很愚蠢,但我怎么能以编程方式告诉CellBrowser重新加载(和显示)数据呢?我猜我需要以某种方式为我的根节点获取AsyncDataProvider的句柄,然后在其上调用updateRowData()和updateRowCount(),但我没有看到查询浏览器(或其模型)的明显方法对于根DataProvider.
我想我可以在我的AsyncDataProvider构造函数中添加代码来查找null参数,并通过这种方式识别"嘿,我是根"并在某处存储引用,但这似乎是hackish.当然有更好的方法来做到这一点.
在这里抛弃这么多代码的道歉,但我不知道如何将其简化为更简单的东西并仍然提供足够的上下文.
我的AsyncDataProvider:
private static class CategoryDataProvider extends AsyncDataProvider<Category>
{
private Category selectedCategory;
private CategoryDataProvider(Category selectedCategory)
{
this.selectedCategory = selectedCategory;
}
@Override
protected void onRangeChanged(HasData<Category> display)
{
new AsyncCall<List<Category>>()
{
@Override
protected void callService(AsyncCallback<List<Category>> cb)
{
// default to root
String categoryId = "-1";
if (selectedCategory != null)
{
categoryId = selectedCategory.getCategoryId();
}
// when a category is clicked, fetch its child categories
service.getCategoriesForParent(categoryId, cb);
}
@Override
public void …Run Code Online (Sandbox Code Playgroud) 是否有可以推荐的CDI/Weld现有或即将出版的书籍?
我正在寻找与Seam in Action类似的东西,这是Seam的一个很好的参考,但现在看起来有点过时了.
我正在尝试使用来自ClientBundleUIBInder模板中的背景图像的图像.我以此讨论为指导,但无法使其发挥作用.
在我的Java类中,我有:
public static interface PriceButtonStyles extends ClientBundle
{
String paidIcon();
@ClientBundle.Source("paid_button_53x31.png")
DataResource paid_buttonAsDataResource();
}
@UiField
PriceButtonStyles priceButtonStyle;
Run Code Online (Sandbox Code Playgroud)
然后在相应的模板文件中我引用它:
<ui:style field="priceButtonStyle" type="com.example.client.PriceButton.PriceButtonStyles">
@url paidIconUrl paid_buttonAsDataResource;
.paidIcon {
background: paidIconUrl 0 0 no-repeat;
}
</ui:style>
Run Code Online (Sandbox Code Playgroud)
在这一点上,我的IDE正在以红色显示"paidIconUrl"字符串,表明某些内容不太正确:

事实上,当我尝试运行它时,我得到:
ERROR: Type com.ecample.client.PriceButton.PriceButtonStyles does not extend com.google.gwt.resources.client.CssResource Element <ui:style field='priceButtonStyle' type='com.example.client.PriceButton.PriceButtonStyles'> (:7).
ERROR: Uncaught exception escaped. com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
Run Code Online (Sandbox Code Playgroud)
在谷歌小组的讨论中,有人建议这可能与之相关,<ui:data>而不是<ui:style>,所以我试图让它发挥作用.但似乎你不能paidIcon()在<ui:data>资源中同时包含CSS样式(例如我的方法)和DataResources .我无法找到很多文档<ui:data> …
我正在将应用程序转换为在其所有页面上使用i18n/l10n.我对Wicket对此的支持感到非常满意,到目前为止一切顺利.我遇到的一个棘手问题是:
我们有一个文本文件,用作HTML模板,用于在用户在网站上执行某项操作时发送电子邮件.当用户单击特定链接时,我手动读取此模板,执行一些文本替换"Dear $USERNAME",并将结果作为HTML电子邮件发送给用户.
为了支持我们目标的10种左右的语言,我要么必须维护这个模板文件的10个副本,要么想办法使用Wicket的内置i18n支持渲染这个"页面",抓住结果作为字符串,然后发送它.
因此我的问题是:如何以编程方式"呈现"Wicket页面并将结果作为字符串获取?
如果可能的话,我宁愿避免像使用HttpClient这样的黑客攻击; HttpClient不会有用户的Locale,也不会以用户等身份自动登录,这对我来说似乎不是一个好的解决方案.
我刚开始使用Rails,所以我正在使用Brakeman来了解我的新手代码中的潜在漏洞.它在我的show.js.erb文件中抛出了一个高可信度的"动态渲染路径"警告:
$('#media-fragment').html('<%= escape_javascript(render(params[:partial])) %>');
Run Code Online (Sandbox Code Playgroud)
我实际上预计这是一个问题,所以毫不奇怪.所以我把它改成了以下内容:
# controller:
def show
if legal_partial?
@allowed_partial = params[:partial]
else
raise StandardError, "unexpected partial request: #{params[:partial]}"
end
end
private
def legal_partial?
%w(screenshots video updates).include? params[:partial]
end
# ...
# show.js.erb
$('#media-fragment').html('<%= escape_javascript(render(@allowed_partial)) %>');
Run Code Online (Sandbox Code Playgroud)
虽然我相信代码现在是安全的,但Brakeman仍对此不满意.是否有更惯用的方法来控制基于用户输入的部分渲染?