Xpath Table
The are two multi-purpose components available, allowing to select one or more items from a list and represent the selected items in a table.
- jp:xpathIntegratedTable A table containing the selected elements with an overlay of all available elements.
- jp:xpathOverlayTable Only the overlay with all available elements
The labelling of column headers is done via dynamic labels and columns (in the overlay panel) can be optionally be search by adding String as a fourth parameter of the JsonTranslationFactory.
Callback Events are available in the bean where this component is used.
The component jp:xpathOverlayTable can be used if the primary table of selected elements is manually handled. Please be aware that
- the op.tbList has to be manually be cleared if the component is used for a single selection (like shown in the example)
<h:form id="fTable">
<jp:xpathIntegratedTable handler="#{tableSelectionXpathBean.opType}" update="@form" tableHeader="jp:xpathIntegratedTable"/>
</h:form>
<h:form id="fPanel">
<p:panel id="pProject" header="jp:xpathOverlayTable" styleClass="jeesl-panel">
<f:facet name="actions">
<j:svg type="jeeslSearch" listener="#{tableSelectionXpathBean.search()}" update=":opStatus" oncomplete="PF('wvStatus').show();"/>
</f:facet>
<p:panelGrid columns="2" columnClasses="jeeslGrid30,jeeslGrid70">
<jtp:label entity="IoFileStatus"/>
<ui:fragment>
<jtp:symbolizer value="#{tableSelectionXpathBean.status}" marginRight="5"/>
<h:outputText value="#{tableSelectionXpathBean.status.name[localeCode].lang}" />
</ui:fragment>
</p:panelGrid>
</p:panel>
</h:form>
<h:form id="opStatus">
<jp:xpathOverlayTable handler="#{tableSelectionXpathBean.opStatus}" widgetVar="wvStatus" update=":fPanel"/>
</h:form>
@Named @ViewScoped
public class TableSelectionXpathBean extends AbstractJeeBean implements Serializable,OpEntityBean
{
final static Logger logger = LoggerFactory.getLogger(TableSelectionXpathBean.class);
private static final long serialVersionUID = 1L;
private OpEntitySelectionHandler<IoFileType> opType; public OpEntitySelectionHandler<IoFileType> getOpType() {return opType;}
private OpEntitySelectionHandler<IoFileStatus> opStatus; public OpEntitySelectionHandler<IoFileStatus> getOpStatus() {return opStatus;}
private IoFileStatus status; public IoFileStatus getStatus() {return status;} public void setStatus(IoFileStatus status) {this.status = status;}
@PostConstruct public void init()
{
super.initSecurity();
opType = new OpEntitySelectionHandler<>(this,fUtils.all(IoFileType.class));
opType.addColumn(JsonTranslationFactory.build(IoFileType.class,JeeslFileType.Attributes.position,OutputXpathPattern.position,"var.position"));
opType.addColumn(JsonTranslationFactory.build(IoFileType.class,JeeslFileType.Attributes.code,OutputXpathPattern.code,"var.code"));
opStatus = new OpEntitySelectionHandler<>(this);
opStatus.addColumn(JsonTranslationFactory.build(IoFileType.class,JeeslFileStatus.Attributes.position,OutputXpathPattern.position,"var.position"));
opStatus.addColumn(JsonTranslationFactory.build(IoFileType.class,JeeslFileStatus.Attributes.code,OutputXpathPattern.code,"var.code"));
opStatus.addColumn(JsonTranslationFactory.build(IoFileType.class,JeeslFileStatus.Attributes.name,OutputXpathPattern.multiLang));
}
public void search()
{
List<IoFileStatus> list = fUtils.all(IoFileStatus.class);
opStatus.setLazy(list);
logger.info("Searched OP Elements "+list.size()+"/"+opStatus.getLazy().getRowCount());
}
@Override
public void addOpEntity(OpSelectionHandler handler, EjbWithId item) throws JeeslLockingException, JeeslConstraintViolationException, JeeslNotFoundException
{
logger.info(item.toString());
if(item instanceof IoFileStatus) {status = (IoFileStatus)item; opStatus.getTbList().clear();}
}
@Override
public void rmOpEntity(OpSelectionHandler handler, EjbWithId item) throws JeeslLockingException, JeeslConstraintViolationException, JeeslNotFoundException
{
logger.info(item.toString());
}
}