好吧,伙计们,我完全无语了。我正在使用 vaadin 框架构建 GUI,但这对问题无关紧要。这是我的代码:
private final boolean readOnly = GenericAdapterFrontendApplication
.getInstance().getUserRole().equals(UserRole.READ);
public InstitutionDetailMasterData(Institution i) {
super(i);
}
protected void createSectionContent(Institution i, Panel p) {
p.addComponent(createRow(
ViewUtils.getMessage("view.institut.masterdata." + PROP_NAME),
i.getName()));
p.addComponent(createRow(
ViewUtils.getMessage("view.institut.masterdata."
+ PROP_DEUBA_ID), i.getDeubaId()));
p.addComponent(createRow(ViewUtils
.getMessage("view.institut.masterdata." + PROP_VARIANT), i
.getVariant().toString()));
p.addComponent(createRow(
ViewUtils.getMessage("view.institut.masterdata."
+ PROP_FIELD_SEP), i.getFieldSeparator()));
p.addComponent(createRow(
ViewUtils.getMessage("view.institut.masterdata."
+ PROP_RECORD_SEP), i.getRecordSeparator()));
p.addComponent(createRow(
ViewUtils.getMessage("view.institut.masterdata."
+ PROP_DATE_FORMAT), i.getDateFormat()));
p.addComponent(createRow(
ViewUtils.getMessage("view.institut.masterdata."
+ PROP_DECIMAL_SEP), i.getDecimalSeparator()));
p.addComponent(createRow(
ViewUtils.getMessage("view.institut.masterdata."
+ PROP_THOUSAND_SEP), i.getThousandSeparator()));
p.addComponent(createRow(ViewUtils
.getMessage("view.institut.masterdata." + PROP_QUOTING), i
.getQuoting()));
p.addComponent(createRow(
ViewUtils.getMessage("view.institut.masterdata."
+ PROP_FREQUENCY), i.getFrequency()));
System.out.println(GenericAdapterFrontendApplication
.getInstance().getUserRole().equals(UserRole.READ));
System.out.println(this.readOnly);
editButton.setVisible(!this.readOnly);
现在重要的部分是 readOnly 在开头的声明和两个打印在结尾,因为你的打印:
true
false
这怎么可能呢?我的意思是我可以使用直接查询来设置按钮的可见性,但是这些值对我来说似乎是不可能的,这让我很困扰。如果有人有解释的想法,请告诉我。谢谢