@Override @SuppressWarnings("unchecked") public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException { try { PickList pickList = (PickList) component; String[][] value = (String[][]) submittedValue; String[] sourceValue = value[0]; String[] targetValue = value[1]; DualListModel model = new DualListModel(); pickList.populateModel(context, sourceValue, model.getSource()); pickList.populateModel(context, targetValue, model.getTarget()); return model; } catch (Exception exception) { throw new ConverterException(exception); } }
@Override protected void validateValue(FacesContext facesContext, Object newValue) { super.validateValue(facesContext, newValue); DualListModel<?> newModel = (DualListModel<?>) newValue; DualListModel<?> oldModel = (DualListModel<?>) getValue(); String clientId = getClientId(facesContext); String label = getLabel(); if (label == null) { label = clientId; } if (isRequired() && newModel.getTarget().isEmpty()) { String requiredMessage = getRequiredMessage(); FacesMessage message = null; if (requiredMessage != null) { message = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage); } else { message = MessageFactory.getMessage(REQUIRED_MESSAGE_ID, FacesMessage.SEVERITY_ERROR, new Object[] {label}); } facesContext.addMessage(clientId, message); setValid(false); } checkDisabled(facesContext, label, newModel.getSource(), oldModel.getSource()); checkDisabled(facesContext, label, newModel.getTarget(), oldModel.getTarget()); }
encodeList(context, pickList, clientId + "_source", PickList.SOURCE_CLASS, model.getSource(), pickList.getFacet("sourceCaption"), pickList.isShowSourceFilter(), true);
@Override public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) { Object ret = null; if (arg1 instanceof PickList) { Object dualList = ((PickList) arg1).getValue(); DualListModel<Map> dl = (DualListModel<Map>) dualList; for (Iterator iterator = dl.getSource().iterator(); iterator.hasNext(); ) { Object o = iterator.next(); String id = (new StringBuilder()).append(o).toString(); if (arg2.equals(id)) { ret = o; break; } } if (ret == null) { for (Iterator iterator1 = dl.getTarget().iterator(); iterator1.hasNext(); ) { Object o = iterator1.next(); String id = (new StringBuilder()).append(o).toString(); if (arg2.equals(id)) { ret = o; break; } } } } return ret; }
public void onFacetTransfer(TransferEvent event) { for (Object item : event.getItems()) { DatasetFieldType facet = (DatasetFieldType) item; if (facetMetadataBlockId != null && !facetMetadataBlockId.equals(facet.getMetadataBlock().getId())) { facets.getSource().remove(facet); } } }
public void onReorderReportGroup() { List<Map<String, String>> lista = new ArrayList<>(); for(Map<String, String> item : reportGroupList.getTarget()) { reportOrderList.getSource().remove(item); reportOrderList.getTarget().remove(item); lista.add(item); } for (Map<String, String> item : reportOrderList.getTarget()){ lista.add(item); } reportOrderList.setTarget(lista); }
@Override public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) { Object ret = null; if (arg1 instanceof PickList) { Object dualList = ((PickList) arg1).getValue(); DualListModel<IBaseEntity> dl = (DualListModel<IBaseEntity>) dualList; for (Iterator iterator = dl.getSource().iterator(); iterator.hasNext(); ) { Object o = iterator.next(); String id = (new StringBuilder()).append(((IBaseEntity) o).getId()).toString(); if (arg2.equals(id)) { ret = o; break; } } if (ret == null) { for (Iterator iterator1 = dl.getTarget().iterator(); iterator1.hasNext(); ) { Object o = iterator1.next(); String id = (new StringBuilder()).append(((IBaseEntity) o).getId()).toString(); if (arg2.equals(id)) { ret = o; break; } } } } return ret; }
public void changeFacetsMetadataBlock() { if (facetMetadataBlockId == null) { facets.setSource(datasetFieldService.findAllFacetableFieldTypes()); } else { facets.setSource(datasetFieldService.findFacetableFieldTypesByMetadataBlock(facetMetadataBlockId)); } facets.getSource().removeAll(facets.getTarget()); }
@Override @SuppressWarnings("unchecked") public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException { try { PickList pickList = (PickList) component; String[][] value = (String[][]) submittedValue; String[] sourceValue = value[0]; String[] targetValue = value[1]; DualListModel model = new DualListModel(); pickList.populateModel(context, sourceValue, model.getSource()); pickList.populateModel(context, targetValue, model.getTarget()); return model; } catch (Exception exception) { throw new ConverterException(exception); } }
encodeList(context, pickList, clientId + "_source", PickList.SOURCE_CLASS, model.getSource(), pickList.getFacet("sourceCaption"), pickList.isShowSourceFilter());