>我无法为布尔变量设置真正的假值 我有以下代码
形式.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml">
<h:form>
<p:panel id="work" styleClass="panelNoBorder">
<p:fieldset toggleable="true" toggleSpeed="500" legend="Core">
<h:panelGrid columns="2" styleClass="panelNoBorder"
rendered="#{javaMB.formNotComplete and !javaMB.formRejected}">
<p:outputLabel value="Form Number"/>
<p:row>
<p:inputText id="formNumber" value="#{javaMB.formNumber}" maxlength="10">
</p:inputText>
</p:row>
<p:outputLabel value="Result"/>
<p:row>
<p:inputText id="result" maxlength="10"
value="#{javaMB.result}">
</p:inputText>
</p:row>
</h:panelGrid>
</p:fieldset>
</p:panel>
</h:form>
</ui:composition>
public class JavaMB {
private boolean formRejected = false;
private boolean formNotComplete = true;
public boolean isFormRejected() {
return formRejected;
}
public void setFormRejected(boolean formRejected) {
this.formRejected = formRejected;
}
public boolean isFormNotComplete() {
return formNotComplete;
}
public void setFormNotComplete(boolean formNotComplete) {
this.formNotComplete = formNotComplete;
}
public void initializeWorkFlow() {
logger.debug("Form: " + FormEntity.getFormId());
if (workflow.getActionType().getActionTypeId() == '5') {
this.setFormNotComplete(false);
} else if (workflow.getActionType().getActionTypeId() == '7') {
this.setFormRejected(true);
} else {
}
}
}
设置的值放在if语句内,if语句工作得很好
问题是我无法正确显示布尔值。控制台中没有错误,
this.setFormNotComplete(false);
this.setFormRejected(true);
有什么想法可以解决这个问题吗?
数据库具有"已批准"和"未批准"的值,因此,如果记录具有 5 或 7,则必须命中这些值,并且不显示面板
在数据库中,我们有一个表工作流和操作类型 ID
设置为记录的操作类型 ID 的 5 正在批准或 7 被拒绝
在这些值上,setFormNotComplete(false 7 if setFormRejected(true 必须采取行动(
<h:panelGrid
rendered="#{javaMB.formNotComplete and !javaMB.formRejected}">
if (workflow.getActionType().getActionTypeId() == '5') {
this.setFormNotComplete(false);
} else if (workflow.getActionType().getActionTypeId() == '7') {
this.setFormRejected(true);
} else {
对于布尔字段,getter 方法名称应该是is<First letter capitalised field name>
,但你的不是。
public boolean isformRejected()
应该public boolean isFormRejected()
,public boolean isformNotComplete()
应该public boolean isFormNotComplete()
所以你的类应该如下。
public class JavaMB {
private boolean formRejected = false;
private boolean formNotComplete = true;
public boolean isFormRejected() {
return formRejected;
}
public void setFormRejected(boolean formRejected) {
this.formRejected = formRejected;
}
public boolean isFormNotComplete() {
return formNotComplete;
}
public void setFormNotComplete(boolean formNotComplete) {
this.formNotComplete = formNotComplete;
}
public void initializeWorkFlow() {
logger.debug("Form: " + FormEntity.getFormId());
if (workflow.getActionType().getActionTypeId() == '5') {
this.setFormNotComplete(false);
} else if (workflow.getActionType().getActionTypeId() == '7') {
this.setFormRejected(true);
} else {
}
}
}