UiEditHandler
The UiEditHandler are utility classes helping to determine if input fields in the user interface are editable or not. There are a couple of implementations available:
- UiEditStatusHandler : Evaluates one or more specific status of an entity. They can be in a allow and/or deny list
- UiEditLogicHandler : Combines multiple UiEditHandlers with AND or OR conditions.
<h:body>
<ui:composition>
<h:form id="fTypes">
<p:dataTable styleClass="jeesl-datatable"
var="t" value="#{handlerEditBean.types}"
selection="#{handlerEditBean.type}" selectionMode="single" rowKey="#{t.id}">
<f:facet name="header">
<j:dtHeader entity="xx" code="listOf"/>
</f:facet>
<p:ajax event="rowSelect" listener="#{handlerEditBean.selectType()}" update=":fPanel"/>
<p:column headerText="Text">
<p:outputLabel value="#{t.code}"/>
</p:column>
<p:column headerText="EH1" styleClass="jeeslCenter">
<j:triCheckmark value="#{handlerEditBean.map1[t]}"/>
</p:column>
<p:column headerText="EH2" styleClass="jeeslCenter">
<j:triCheckmark value="#{handlerEditBean.map2[t]}"/>
</p:column>
<p:column headerText="EH3" styleClass="jeeslCenter">
<j:triCheckmark value="#{handlerEditBean.map3[t]}"/>
</p:column>
</p:dataTable>
</h:form>
<h:form id="fPanel">
<p:panel header="Edit" styleClass="jeesl-panel">
<f:facet name="actions">
<j:svg type="jeeslSave" rendered="#{handlerEditBean.eh3.allow}" listener="#{handlerEditBean.save()}"/>
</f:facet>
<p:panelGrid columns="2" columnClasses="jeeslGrid30,jeeslGrid70">
<p:outputLabel value="Label"/>
<p:inputText value="#{handlerEditBean.txt}" rendered="#{handlerEditBean.eh3.allow}"/>
<h:outputText value="#{handlerEditBean.txt}" rendered="#{handlerEditBean.eh3.deny}"/>
</p:panelGrid>
</p:panel>
</h:form>
<h:form id="fBoolean">
<p:panel header="Boolean" styleClass="jeesl-panel">
<f:facet name="actions">
<j:svg type="jeeslSave" listener="#{handlerEditBean.save()}" rendered="#{handlerEditBean.eh3.allow}"/>
<j:svg type="jeeslEdit" listener="#{handlerEditBean.ehBool.toggle()}" update="@form"
styleClass="#{handlerEditBean.ehBool.allow ? '' : 'jeesl-greyscale'}"/>
</f:facet>
<j:inputGrid>
<p:outputLabel value="Edit?"/>
<j:duoCheckmark value="#{handlerEditBean.ehBool.allow}"/>
</j:inputGrid>
</p:panel>
</h:form>
@Named @ViewScoped
public class HandlerEditBean extends AbstractJeeBean implements Serializable
{
final static Logger logger = LoggerFactory.getLogger(HandlerEditBean.class);
private static final long serialVersionUID = 1L;
private UiEditStatusHandler<IoFileType> eh1; public UiEditStatusHandler<IoFileType> getEh1() {return eh1;}
private UiEditStatusHandler<IoFileType> eh2; public UiEditStatusHandler<IoFileType> getEh2() {return eh2;}
private final UiEditBooleanHandler ehBool; public UiEditBooleanHandler getEhBool() {return ehBool;}
private UiEditLogicHandler eh3; public UiEditLogicHandler getEh3() {return eh3;}
private List<IoFileType> types; public List<IoFileType> getTypes() {return types;}
private final Map<IoFileType,Boolean> map1; public Map<IoFileType,Boolean> getMap1() {return map1;}
private final Map<IoFileType,Boolean> map2; public Map<IoFileType,Boolean> getMap2() {return map2;}
private final Map<IoFileType,Boolean> map3; public Map<IoFileType,Boolean> getMap3() {return map3;}
private IoFileType type;
public IoFileType getType() {return type;}
public void setType(IoFileType type) {this.type = type;}
private String txt; public String getTxt() {return txt;} public void setTxt(String txt) {this.txt = txt;}
public HandlerEditBean()
{
eh1 = new UiEditStatusHandler<>();
eh2 = new UiEditStatusHandler<>();
eh3 = new UiEditLogicHandler(UiEditLogicHandler.Type.AND);
eh3.addHandler(eh1);
eh3.addHandler(eh2);
ehBool = new UiEditBooleanHandler();
map1 = new HashMap<>();
map2 = new HashMap<>();
map3 = new HashMap<>();
}
@PostConstruct public void init()
{
super.initSecurity();
types = fUtils.allOrderedPositionVisible(IoFileType.class);
eh1.addAllow(types.get(1));
eh2.addDeny(types.get(2));
for(IoFileType t : types)
{
eh1.update(t); map1.put(t,eh1.isAllow());
eh2.update(t); map2.put(t,eh2.isAllow());
eh3.update(); map3.put(t,eh3.isAllow());
}
}
public void selectType()
{
logger.info(type.toString());
eh1.update(type);
eh2.update(type);
eh3.update();
}
public void save() {}
}
public interface UiEditHandler extends Serializable
{
boolean isAllow();
boolean isDeny();
}
Resource not found:
/jeesl/java/org/jeesl/controller/handler/ui/edit/UiEditStatusHandler.java
must be available in the classpath