Map<String, String> params = context.getExternalContext().getRequestParameterMap(); String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM); String clientId = getClientId(context); String[] idTokens = dragId.split(String.valueOf(UINamingContainer.getSeparatorChar(context))); int rowIndex = Integer.parseInt(idTokens[idTokens.length - 2]); datasource.setRowIndex(rowIndex); Object data = datasource.getRowData(); datasource.setRowIndex(-1);
for (UIComponent column : data.getChildren()) { for (int i = 0; i < dynamicColumns.size(); i++) { DynamicColumn dynamicColumn = dynamicColumns.get(i); for (UIComponent comp : column.getChildren()) { clientIds += data.getClientId(context) + seperatorChar + row + seperatorChar + dynamicColumn.getId() + seperatorChar + i + seperatorChar + comp.getId(); for (UIComponent cell : column.getChildren()) { clientIds += data.getClientId(context) + seperatorChar + row + seperatorChar + cell.getId();
protected int validate(FacesContext context, UIComponent source, UIComponent last, String expression) { if (!(last instanceof UIData)) { throw new FacesException("The last resolved component must be instance of UIData to support @row. Expression: \"" + expression + "\" referenced from \"" + last.getClientId(context) + "\"."); } try { Matcher matcher = PATTERN.matcher(expression); if (matcher.matches()) { int row = Integer.parseInt(matcher.group(1)); if (row < 0) { throw new FacesException("Row number must be greater than 0. Expression: \"" + expression + "\""); } UIData data = (UIData) last; if (data.getRowCount() < row + 1) { throw new FacesException("The row count of the target is lesser than the row number. Expression: \"" + expression + "\""); } return row; } else { throw new FacesException("Expression does not match following pattern @row(n). Expression: \"" + expression + "\""); } } catch (Exception e) { throw new FacesException("Expression does not match following pattern @row(n). Expression: \"" + expression + "\"", e); } }
@Override public void invokeContextCallback(FacesContext fc, UIComponent component) { UIData uiData = (UIData) component; String[] idTokens = dragId.split(String.valueOf(UINamingContainer.getSeparatorChar(fc))); int rowIndex = Integer.parseInt(idTokens[idTokens.length - 2]); uiData.setRowIndex(rowIndex); data = uiData.getRowData(); uiData.setRowIndex(-1); }
throws IOException if (!component.isRendered()) if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) clientId = component.getClientId(context); ResponseWriter writer = context.getResponseWriter(); writer.startElement("span", component); writer.writeAttribute("id", clientId, "id"); int first = data.getFirst(); int rows = data.getRows(); data.setRowIndex(i); if (!data.isRowAvailable()) if (i!=first) writer.write(separator); Iterator iter = data.getChildren().iterator(); while (iter.hasNext())
private void setRowIndexWithoutRowStatePreserved(int rowIndex){ saveDescendantState(); getStateHelper().put(PropertyKeys.rowIndex, rowIndex); DataModel localModel = getDataModel(); localModel.setRowIndex(rowIndex); setDataModel(null); String var = (String) getStateHelper().get(PropertyKeys.var); if (var != null) { Map<String, Object> requestMap = getFacesContext().getExternalContext().getRequestMap(); if (rowIndex == -1) { oldVar = requestMap.remove(var); } else if (isRowAvailable()) { requestMap.put(var, getRowData()); } else { requestMap.remove(var); restoreDescendantState();
ResponseWriter writer = context.getResponseWriter(); int rowIndex = data.getFirst() - 1; int rows = data.getRows(); List<Integer> bodyRows = getBodyRows(context.getExternalContext().getApplicationMap(), data); boolean hasBodyRows = (bodyRows != null && !bodyRows.isEmpty()); boolean wroteTableBody = false; data.setRowIndex(++rowIndex); if (!data.isRowAvailable()) { break; // Scrolled past the last row if (hasBodyRows && bodyRows.contains(data.getRowIndex())) { if (wroteTableBody) { writer.endElement("tbody"); writer.startElement("tbody", data); wroteTableBody = true; data.setRowIndex(-1);
ResponseWriter writer = context.getResponseWriter(); int first = data.getFirst(); int rows = data.getRows(); data.setRowIndex(i); if (!data.isRowAvailable()) writer.startElement("tr", data); Iterator iter = data.getChildren().iterator(); while (iter.hasNext()) writer.startElement("td", child); writer.write("debug UIColumn"); RendererUtil.encodeRecursive(context, child); writer.endElement("td"); writer.write("debug UIData"); child.encodeBegin(context); child.encodeChildren(context); child.encodeEnd(context);
@Override public void setRowIndex(int rowIndex) { super.setRowIndex(rowIndex); String rowIndexVar = getRowIndexVar(); String rowCountVar = getRowCountVar(); if (rowIndexVar != null || rowCountVar != null) { Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap(); if (rowIndex >= 0) { // regular row index, update request scope variables if (rowIndexVar != null) { requestMap.put(getRowIndexVar(), new Integer(rowIndex)); } if (rowCountVar != null) { requestMap.put(getRowCountVar(), new Integer(getRowCount())); } } else { // rowIndex == -1 means end of loop --> remove request scope // variables if (rowIndexVar != null) { requestMap.remove(getRowIndexVar()); } if (rowCountVar != null) { requestMap.remove(getRowCountVar()); } } } }
protected void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException{ UIData uiData = (UIData) component; ResponseWriter writer = facesContext.getResponseWriter(); int first = uiData.getFirst(); int rows = uiData.getRows(); int last; if (rows <= 0) { last = uiData.getRowCount(); if (last > uiData.getRowCount()) { last=uiData.getRowCount(); uiData.setRowIndex(idx); if(!uiData.isRowAvailable()) { log.error("Row is not available. Rowindex = " + idx); break; writer.startElement(HTML.TR_ELEM, component); writer.writeAttribute("value", Integer.toString(idx + 1), null); List children = getChildren(component); for (int j = 0, size = getChildCount(component); j < size; j++) { UIComponent child = (UIComponent) children.get(j); if (child.isRendered()) { boolean columnRendering = child instanceof UIColumn; if (columnRendering) writer.endElement(HTML.TR_ELEM);
/** * Renders the start of a new row of body content. * @param facesContext the <code>FacesContext</code>. * @param writer the <code>ResponseWriter</code>. * @param uiData the <code>UIData</code> being rendered. * @throws IOException if an exceptoin occurs. */ protected void renderRowStart( FacesContext facesContext, ResponseWriter writer, UIData uiData, Styles styles, int rowStyleIndex) throws IOException { writer.startElement(HTML.TR_ELEM, null); // uiData); renderRowStyle(facesContext, writer, uiData, styles, rowStyleIndex); Object rowId = uiData.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.ROW_ID); if (rowId != null) { writer.writeAttribute(HTML.ID_ATTR, rowId.toString(), null); } }
public static void execute(UIData uiData, Invoker invoker) { if (uiData== null || !uiData.getAttributes().containsKey(DataPaginatorGroup.class.getName())) return; List dataPaginatorClientIdList = (List) uiData.getAttributes().get(DataPaginatorGroup.class.getName()); Iterator it = dataPaginatorClientIdList.iterator(); FacesContext facesContext = FacesContext.getCurrentInstance(); while (it.hasNext()) { UIComponent component = CoreComponentUtils.findComponent(UINamingContainer.getSeparatorChar(facesContext) + String.valueOf(it.next()), facesContext.getViewRoot()); if (component != null && component.isRendered() && component instanceof DataPaginator) { invoker.invoke((DataPaginator)component); } } }
public void setRowIndex(int rowIndex) { saveDescendantState(); this.rowIndex = rowIndex; DataModel model = getDataModel(); model.setRowIndex(rowIndex); String var = getVar(); if (var != null) { Map requestMap = getFacesContext().getExternalContext() .getRequestMap(); if (rowIndex == -1) { requestMap.remove(var); } else if (isRowAvailable()) { requestMap.put(var, getRowData()); } else { requestMap.remove(var); } } restoreDescendantState(); }
UIComponent detailStampFacet = uiData.getFacet(DETAIL_STAMP_FACET_NAME); ResponseWriter writer = facesContext.getResponseWriter(); writer.startElement(HTML.TR_ELEM, uiData); writer.startElement(HTML.TD_ELEM, uiData); for (Iterator childIter = uiData.getChildren().iterator(); childIter.hasNext();) writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer( childCount), null);
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } ((HtmlTable) component).clearMetaInfo(context, component); ((UIData) component).setRowIndex(-1); renderTableEnd(context.getResponseWriter()); }
protected void processColumnsChildren(FacesContext context, PhaseId phaseId) { int first = getFirst(); int rows = getRows(); int last = (rows != 0) ? (first + rows) : getRowCount(); for (int rowIndex = first; rowIndex < last; rowIndex++) { setRowIndex(rowIndex); if (!isRowAvailable()) { continue; } for (Iterator children = getChildren().iterator(); children .hasNext();) { UIComponent child = (UIComponent) children.next(); if (!(child instanceof UIColumn)) { continue; } for (Iterator grandChildren = child.getChildren().iterator(); grandChildren .hasNext();) { UIComponent grandChild = (UIComponent) grandChildren.next(); if (!grandChild.isRendered()) { continue; } ComponentUtil_.processAppropriatePhaseAction(context, grandChild, phaseId); } } } setRowIndex(-1); }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { rendererParamsNotNull(context, component); if (!shouldEncode(component)) { return; } clearMetaInfo(context, component); ((UIData) component).setRowIndex(-1); // Render the ending of this table renderTableEnd(context, component, context.getResponseWriter()); }
/** * Perform any operations necessary in the TBODY start tag. * * @param facesContext the <code>FacesContext</code>. * @param uiData the <code>UIData</code> being rendered. */ protected void inBodyStart(FacesContext facesContext, UIData uiData) throws IOException { String bodyStyleClass; String bodyStyle; if (uiData instanceof HtmlDataTable) { bodyStyleClass = ((HtmlDataTable) uiData).getBodyStyleClass(); bodyStyle = ((HtmlDataTable) uiData).getBodyStyle(); } else { bodyStyleClass = (String) uiData.getAttributes().get(BODY_STYLE_CLASS); bodyStyle = (String) uiData.getAttributes().get(BODY_STYLE); } ResponseWriter writer = facesContext.getResponseWriter(); if (bodyStyleClass != null) { writer.writeAttribute(HTML.CLASS_ATTR, bodyStyleClass, BODY_STYLE_CLASS); } if (bodyStyle != null) { writer.writeAttribute(HTML.STYLE_ATTR, bodyStyle, BODY_STYLE); } }
protected void saveChild(FacesContext facesContext, UIComponent uiComponent) { super.saveChild(facesContext, uiComponent); if (uiComponent instanceof UIData) { String clientId = uiComponent.getClientId(facesContext); savedChildren.put(clientId, ((UIData) uiComponent).getValue()); } }
private void processRows(FacesContext context, int processAction) { UIData parentUIData = getParentUIData(); int first = parentUIData.getFirst(); int rows = parentUIData.getRows(); int last; if (rows == 0) { last = parentUIData.getRowCount(); } else { last = first + rows; } for (int rowIndex = first; rowIndex < last; rowIndex++) { parentUIData.setRowIndex(rowIndex); if (parentUIData.isRowAvailable()) { processColumns(context, processAction); } } }