i have a question.. I didnt find out, how i must realise somtehing that i could set for eache cell a own color. Now i had tried to make a new Attribute in the p:colums tag myself to add a new Attribute called colorPerCell. The idea is, that i could see a Methodeexpressen, whiche return a color, like red for example. In the DatatableRenderer.java i have insertet a new line, where the td-tag is rendered. Means in encodeTable(). But my Problem is, that the attribute never will be rendered on page. Could it be, that the yui-framwork override this attribut? And would it be possible to call this methode after yui has formattet the table. ..
Further a problem withe the p:printer-tag will be solved to for me. Because if i could add the display:none in the rowInde-Row, than the p:printer want print this td-tag. otherwise i thinke, that the jqprinter-script didnt realise, that in the css of yui this row will be hidden. Because for me , until knp0ow, that attibute will be printet too.
Here the source:
int ColumTag.java
Code: Select all
private javax.el.ValueExpression _colorPerCell;
encodeTable() from DatadableRenderer.java
//only two new lines... but they will now be shown on page, why???a
Code: Select all
protected void encodeTable(FacesContext facesContext, DataTable dataTable) throws IOException {
System.out.println("encodeTable(FacesContext facesContext, DataTable dataTable)");
ResponseWriter writer = facesContext.getResponseWriter();
String clientId = dataTable.getClientId(facesContext);
Object selection = dataTable.getSelection();
boolean selectionEnabled = dataTable.isSelectionEnabled() && selection != null;
boolean isSingleSelection = dataTable.isSingleSelectionMode();
if(dataTable.isLazy() && dataTable.getValue() instanceof LazyDataModel<?>) {
dataTable.loadLazyData();
}
writer.startElement("table", null);
writer.writeAttribute("id", clientId + "_table", null);
writer.writeAttribute("style", "display:none", null);
writer.startElement("tbody", null);
int rowCountToRender = getNumberOfRowsToRender(dataTable);
int first = dataTable.getFirst();
for(int i = first; i < (first + rowCountToRender); i++) {
dataTable.setRowIndex(i);
if(!dataTable.isRowAvailable())
continue;
// Selection
if(selectionEnabled && isSelected(dataTable.getRowData(), selection, isSingleSelection)) {
dataTable.getSelectedRowIndexes().add(dataTable.getRowIndex());
}
// Row index var
if(dataTable.getRowIndexVar() != null) {
facesContext.getExternalContext().getRequestMap().put(dataTable.getRowIndexVar(), i);
}
writer.startElement("tr", null);
//rowIndex
writer.startElement("td", null);
writer.writeAttribute("style", "display:none", null);
System.out.println("Set the style on display:none");
writer.write(String.valueOf(dataTable.getRowIndex()));
writer.endElement("td");
for(Iterator<UIComponent> iterator = dataTable.getChildren().iterator(); iterator.hasNext();) {
UIComponent kid = iterator.next();
if(kid.isRendered() && kid instanceof Column) {
Column column = (Column) kid;
writer.startElement("td", null);
writer.writeAttribute("style", "background-color:"+column.getColorPerCell(), null);
System.out.println("background-color:"+column.getColorPerCell());
renderChildren(facesContext, column);
writer.endElement("td");
}
}
writer.endElement("tr");
}
Thanks
Manuel