我有一个使用MyBatis访问PostgreSQL数据库的Java项目.PostgreSQL允许在INSERT
语句后返回新创建的行的字段,我想用它来返回自动生成BIGSERIAL
id
的新创建的记录.因此,我insert
将XML中的命令更改为使用PostgreSQL的功能,resultType="long"
向<insert>
标记添加属性,并在映射器的Java接口中设置插入方法long
而不是返回void
.
当我尝试运行时,我得到一个org.xml.sax.SAXParseException
说法Attribute "resultType" must be declared for element type "insert"
.
现在,当我将<insert>
标签更改为<select>
一切正常时,但我使用<select>
标签执行INSERT
语句让我感到困扰.
有没有办法让映射到<insert>
标签的方法返回结果,或者MyBatis是不是为此设计的,我应该将它们作为<select>
标签保存?
我最近在Java中乱用ClassLoaders,试图测试使用动态加载类(使用Class.forName(String name)
)和自定义的代码ClassLoader
.
我有自己的自定义ClassLoader
设置,应该可配置为ClassNotFoundException
在尝试加载给定的类时抛出.
public class CustomTestClassLoader extends ClassLoader {
private static String[] notAllowed = new String[]{};
public static void setNotAllowed(String... nonAllowedClassNames) {
notAllowed = nonAllowedClassNames;
}
public static String[] getNotAllowed() {
return notAllowed;
}
public CustomTestClassLoader(ClassLoader parent){super(parent);}
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
for (String s : notAllowed) {
if (name.equals(s)) {
throw new ClassNotFoundException("Loading this class is not allowed for testing purposes.");
}
}
if(name.startsWith("java") || name.startsWith("sun") …
Run Code Online (Sandbox Code Playgroud) 我p:outputLabel
在使用复合组件时遇到问题.我有复合组件与p:inputText
字段(我从组件中删除了不相关的部分):
<cc:interface>
<cc:editableValueHolder name="myInput" targets="myInput"/>
<cc:attribute name="required" required="true" type="java.lang.Boolean" default="false"/>
</cc:interface>
<cc:implementation>
<p:inputText id="myInput" required="#{cc.attrs.required}"/>
</cc:implementation>
Run Code Online (Sandbox Code Playgroud)
现在,我不会将此组件用于p:outputLabel
:
<p:outputLabel for="myComponent:myInput" value="#{resources['myLabel']}:"/>
<my:myComponent id="myComponent" required="#{myBean.required}"/>
Run Code Online (Sandbox Code Playgroud)
一切正常,需要验证,也会显示消息,但*
标签上没有标记,因为我将标签直接连接到p:inputText
组件时.如果是我,而另一方面,硬编码required="true"
在p:inputText
一切工作正常.
我通过调试org.primefaces.component.outputlabel.OutputLabelRenderer
并发现组件被识别为UIInput
,但input.isRequired()
返回false.进一步调试发现该required
属性尚未在组件上定义,因此它返回false
默认值i UIInput
:
(Boolean) getStateHelper().eval(PropertyKeys.required, false);
Run Code Online (Sandbox Code Playgroud)
此外,如果我只是p:outputLabel
在复合组件内移动一切正常.像EL一样,后来在复合元件内进行评估?
我正在使用Primefaces 3.5和Mojarra 2.1.14
如何捕获p:dataTable
PrimeFaces中的事件过滤.我需要在过滤时计算与结果列表关联的一些值,并且我必须使用过滤表进行计算:
<p:dataTable id="tabla_gral" rendered="#{consumoMaterial.verTabla}" var="item"
paginator="true" rows="15" rowKey="#{item.no}"
value="#{consumoMaterial.listadoConsumo}"
filteredValue="#{consumoMaterial.listadoConsumoFiltered}">
Run Code Online (Sandbox Code Playgroud)
但我想每次使用滤液时都要进行计算.
我正在尝试显示在新浏览器窗口中打开的内联PDF.我有以下场景:
window.open
打开新页面以显示PDF)在打开的页面上我只有p:media
标签里面h:body
的值指向StreamedContent
:
现在,在该页面上我的PDF不会生成.在日志中我可以看到这两行:
org.primefaces.application.PrimeResourceHandler handleResourceRequest
SEVERE: Error in streaming dynamic resource. Expression cannot be null
Run Code Online (Sandbox Code Playgroud)
我开始调试并找出一些东西.
首先,我将断点添加到@PostConstruct
我的RequestScoped
bean的方法中.有趣的是,断点达到了两次,并且在PDF显示完美之后让我大吃一惊?!
经过一些调试后,PrimeResourceHandler
我发现在某些情况下ValueExpression
没有计算,实际上它会抛出NullPointerException
,并且在调试时我再次看到发送了两个请求,第二个请求失败,因为dynamicContentId
在第一个请求中删除了,第二个调用handleResourceRequest
没有有意义.
通过Firebug我可以看到两个请求,第一个是PDF数据,第二个也是内容类型application/pdf但是空,大小为0.
xhtml页面:
<html>
<h:head></h:head>
<h:body>
<p:media value="#{reportBean.streamedContent}" player="pdf" width="500" height="500"/>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
支持豆:
@RequestScoped
public class StampaListeBackingBean implements Serializable {
private static final long serialVersionUID = 1L;
private StreamedContent streamedContent;
@PostConstruct
public void init() {
Map<String, Object> session = …
Run Code Online (Sandbox Code Playgroud) 我有JSF验证的特定用例.例如,我有一个inputText
字段:
<p:inputText id="input" required="#{myBean.required}" value="#{myBean.value}" maxlength="20" disabled="#{myBean.disabled}">
<p:ajax event="blur" process="@this" update="name" listener="#{myBean.listener}"/>
</p:inputText>
Run Code Online (Sandbox Code Playgroud)
输入的值是数字(在某些情况下,它也可以是一个字符串,因为这是复合组件的一部分,但如果我们假设这是一个数字,则可以更好地描述问题).此输入是表单的一部分,在表单的末尾我有提交按钮:
<p:commandButton value="Save" actionListener="#{myBean.save}"/>
Run Code Online (Sandbox Code Playgroud)
我的要求是什么:
name
带有一些值的id的字段.name
.这也是当我除去其在输入已经输入的文本,从组分(按TAB例如)移除焦点的情况下,并在这种情况下AJAX请求也应当被处理和姓名输入也将被清除.我是如何禁用此输入字段的验证,如果它是空的,只是为了这个ajax事件?
所以我有一个非常复杂的dataTable.它应该能够编辑单行,选择多行,并显示每行的上下文菜单.单行编辑工作正常,多选工作也是如此,我唯一的问题是每当我尝试在右键单击的行上打开contextMenu时,所选tableItem的值为null.只有当我在行上单击显式(左键单击),然后右键单击上下文菜单才会显示它.这非常不方便,我想在右键单击contextMenu以显示所选的itemValue.
我知道有关于这个问题的其他帖子,但没有真正的解决方案或解决方法,所以我希望你能帮助我.
这是我的代码:
<p:contextMenu id="schadenTableContextMenu" for="todoSchadenTable"
style="width: 200px; ">
<p:submenu id="schadenTableSetAsReadSBM" label="Markieren als"
styleClass="my-menu">
<p:menuitem id="schadenTableSetAsReadSBMMI1" value="Gelesen"
style="width: 167px;" icon="ui-icon-mail-open" ajax="true"
partialSubmit="true" process="@this"
action="#{todoLeseHistController.setAlsGelesen()}" update=":mainForm" />
<p:menuitem id="schadenTableSetAsReadSBMMI2" value="Ungelesen"
style="width: 167px;" icon="ui-icon-mail-closed" ajax="true"
partialSubmit="true" process="@this"
action="#{todoLeseHistController.setAlsUngelesen()}"
update=":mainForm" />
</p:submenu>
<p:menuitem id="schadenTableContextMenuMI3"
style="width:190px !important; font-size:12px !important;"
value="In der Applikation öffnen" icon="ui-icon-pencil"
title="Öffnet den ToDo in der entsprechenden Applikation." ajax="true"
partialSubmit="true" process="@this"
action="#{openExternalLinkController.openTodoInExtUrl()}"
oncomplete="openExternal(xhr, status, args)" update=":msgGrowl" />
</p:contextMenu>
-------------------dataTable-----------------
<p:dataTable id="todoSchadenTable" widgetVar="todoSchadenTableW"
emptyMessage="Keine Schadenmeldungen gefunden." var="currentTableItem"
value="#{schadenTableController.dataModel}" paginator="true" rows="15"
filteredValue="#{schadenTableController.filteredTodos}"
filterEvent="keyup" …
Run Code Online (Sandbox Code Playgroud) 我正在寻找在 IDE 中运行/调试任务和 dags 的最佳方法。我发现有两种方法可以做到这一点。airflow test
我可以在调试模式下针对特定 dag 和可选任务运行命令。另一种方法是使用DebugExecutor
并运行特定的 dag。我发现这两种方式都需要 Airflow 数据库启动并运行,并且所有池都已配置(可能还有队列)。我的问题是:
airflow test
使用DebugExecutor
在幕后我正在使用primefaces 3.3.1和JSF 2(Mojarra 2.1.9).
我有一个带有DataTable组件和Dialog的页面,用于显示DataTable条目的详细信息.当我有一个对话框时,这很简单.我想要的是尝试允许用户同时打开两个或三个带有不同条目细节的dailog.有人知道如何从服务器获取AJAX的整个对话,而不仅仅是对话框内容吗?
primefaces ×6
jsf-2 ×4
ajax ×3
airflow ×2
jsf ×2
classloader ×1
datatable ×1
debugging ×1
dialog ×1
java ×1
media ×1
mybatis ×1
pdf ×1
postgresql ×1
required ×1
stream ×1
testing ×1
unit-testing ×1
validation ×1
xhtml ×1