我开始学习JPA,并基于我在SQL Server中测试的以下本机SQL实现了JPA查询的示例:
SELECT f.StudentID, f.Name, f.Age, f.Class1, f.Class2
FROM Student f
LEFT OUTER JOIN ClassTbl s ON s.ClassID = f.Class1 OR s.ClassID = f.Class2
WHERE s.ClassName = 'abc'
Run Code Online (Sandbox Code Playgroud)
从上面的SQL我构建了以下JPQL查询:
SELECT f FROM Student f LEFT JOIN f.Class1 s;
Run Code Online (Sandbox Code Playgroud)
如您所见,我仍然缺少OR s.ClassID = f.Class2原始查询的条件.我的问题是,我怎样才能把它放到我的JPQL中?
我想从我的Ipad禁用键盘弹出窗口,所以我做了这样的事情,但这不是我的愿望.
我有一个文本框:
<h:inputText id="txtDate" value="#{myDateController.selected.DOB}"
Run Code Online (Sandbox Code Playgroud)
我尝试使用"readonly"属性,但数据无法保存到数据库.我也用这个:$("#frmEdit \:txtDate").attr("disabled",true) - >但是不行
我在网上搜索并使用此链接应用我的代码,但它也不行:ipad web应用程序:如何防止键盘弹出jquery datepicker
$(function() {
//$("#frmEdit\\:txtDate").attr("disabled", true)
$("#frmEdit\\:txtDate").datetimepicker({
// showOn: "button"
showOn: "both",
buttonImage: "../images/calendar.png",
buttonImageOnly: true,
constrainInput: true,
showButtonPanel: true,
dateFormat: 'dd-M-yy',
addSliderAccess: true,
sliderAccessArgs: { touchonly: false },
onClose: function(dateText, inst){
$(this).attr("disabled", false);
},
beforeShow: function(input, inst){
$(this).attr("disabled", false);
}
});
});
Run Code Online (Sandbox Code Playgroud)
我的代码出了什么问题?或任何其他解决方案吗?非常感谢
我正在验证我的表单,我可以获得textbox的值,但总是在uiClass变量(Error: java.lang.NullPointerException)中检索null值:有什么建议吗?
例外:
WARNING: /jsf/report/Edit.xhtml @39,99 listener="#{studentController.validate}": java.lang.NullPointerException
javax.el.ELException: /jsf/report/Edit.xhtml @39,99 listener="#{studentController.validate}": java.lang.NullPointerException
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:131)
at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2464)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106)
at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2168)
at com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2116)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:288)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:246)
Caused by: java.lang.NullPointerException
at entities.StudentController.validate(StudentController.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
@ManagedBean()
@SessionScoped
public class StudentController implements Serializable {
public void validate(ComponentSystemEvent event) {
FacesContext fc = FacesContext.getCurrentInstance();
UIComponent components = event.getComponent();
UIInput uiName = (UIInput) components.findComponent("frmStudent:name");
UIInput uiClass = (UIInput) components.findComponent("frmStudent:myclass");
String name = uiName.getLocalValue().toString(); …Run Code Online (Sandbox Code Playgroud) 在我的代码中,我使用Primefaces的日历
<p:calendar id="cal" value="#{accountController.selected.mydate}" styleClass="custom" pattern="dd-MMM-yyyy HH:mm" />
Run Code Online (Sandbox Code Playgroud)
所以我想问:如果我使用pattern ="dd-MMM-yyyy HH:mm",如何防止日历文本框中的用户输入数据?
在Primefaces中有任何与Richfaces的enableManualInput属性等效的属性吗?
谢谢你的帮助