Ron*_*got 6 java postgresql jsf boolean jpa
我有Postgresql 8.4表
CREATE TABLE users
(
username character varying(50) NOT NULL,
"password" character varying(50) NOT NULL,
enabled boolean NOT NULL,
type_of_signature boolean NOT NULL,
companyusers2_id integer NOT NULL,
numberorganizac character(8) NOT NULL,
);
Run Code Online (Sandbox Code Playgroud)
在该表中,我只有一行:""admin";"admin"; TRUE; TRUE; 1;"12345678"
我有JPA
@Entity
@Table(name="users")
public class Users implements Serializable {
...
private boolean typeOfSignature;
...
@Column(name="type_of_signature")
public boolean getTypeOfSignature() {
return this.typeOfSignature;
}
public void setTypeOfSignature(boolean typeOfSignature) {
this.typeOfSignature = typeOfSignature;
}
...
}
Run Code Online (Sandbox Code Playgroud)
我有JSF
<h:outputText value="Type of signature is NULL" rendered="#{curUser.typeOfSignature == null}"/>
<h:outputText value="Type of Signature is TRUE" rendered="#{curUser.typeOfSignature}"/>
<h:outputText value="Type of Signature is FALSE" rendered="#{!curUser.typeOfSignature}"/>
Run Code Online (Sandbox Code Playgroud)
我总是在结果页面上得到"签名类型为签名的NULL类型为FALSE".
但我的豆子里也有方法
if(getCurUser().getTypeOfSignature())
{
jpaBean.pushSignature(dataItem, 1);
}
else
{
jpaBean.pushSignature(dataItem, 2);
}
Run Code Online (Sandbox Code Playgroud)
它根据用户签名的类型正常工作.
为什么我总是在JSF中得到NULL?或者我是一个新手并做错了什么?
你试过了吗:
<h:outputText value="Type of signature is True" rendered="#{true}"/>
<h:outputText value="Type of signature is False" rendered="#{false}"/>
Run Code Online (Sandbox Code Playgroud)
?
如果这些失败,则意味着值绑定器出现问题。它不应该用于基本的 html 元素。
import javax.faces.component.ActionSource;
import javax.faces.component.UIComponent;
import javax.faces.component.ValueHolder;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.el.ValueBinding;
public class MyHtmlOutputText extends HtmlOutputText {
public boolean isRendered() {
if (rendered != null) {
return rendered;
}
ValueBinding vb = getValueBinding("rendered");
Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
return v != null ? v : DEFAULT_DISABLED;
}
public boolean getRendered() {
return isRendered();
}
}
Run Code Online (Sandbox Code Playgroud)
由于某种原因,我不存储值绑定的结果。这个原因是因为存储到状态中的值将不再在运行时从原始表达式解析。这是我们绝对不希望看到的。
在那里您将找到如何将MyHtmlOutputText
组件注册到facelets上下文中:http://hanzz.lbs-logics.at/index.php? option=com_content&task=view&id=107&Itemid=31
归档时间: |
|
查看次数: |
967 次 |
最近记录: |