本文整理汇总了Java中javax.faces.component.UIData.getRows方法的典型用法代码示例。如果您正苦于以下问题:Java UIData.getRows方法的具体用法?Java UIData.getRows怎么用?Java UIData.getRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.component.UIData
的用法示例。
在下文中一共展示了UIData.getRows方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeInnerHtml
import javax.faces.component.UIData; //导入方法依赖的package包/类
public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException {
UIData uiData = (UIData) component;
ResponseWriter writer = facesContext.getResponseWriter();
Styles styles = getStyles(uiData);
int first = uiData.getFirst();
int rows = uiData.getRows();
int rowCount = uiData.getRowCount();
if (rows <= 0)
{
rows = rowCount - first;
}
int last = first + rows;
if (last > rowCount)
last = rowCount;
for (int i = first; i < last; i++)
{
uiData.setRowIndex(i);
if (!uiData.isRowAvailable())
{
log.warn("Row is not available. Rowindex = " + i);
return;
}
int columns = component.getChildCount();
renderCategoryRow(i, columns, uiData, writer, i==first);
beforeRow(facesContext, uiData);
HtmlRendererUtils.writePrettyLineSeparator(facesContext);
renderRowStart(facesContext, writer, uiData, styles, i);
List children = component.getChildren();
for (int j = 0, size = component.getChildCount(); j < size; j++)
{
UIComponent child = (UIComponent) children.get(j);
if(child.isRendered())
{
encodeColumnChild(facesContext, writer, uiData, child, styles, j);
}
}
renderRowEnd(facesContext, writer, uiData);
afterRow(facesContext, uiData);
}
}
示例2: renderData
import javax.faces.component.UIData; //导入方法依赖的package包/类
/**
* Core workhouse method of the dynamic renderers.
* @param context FacesContext
* @param component UIComponent
* @throws IOException
*/
protected void renderData(FacesContext context, UIComponent component) throws
IOException
{
boolean multiColumn = component instanceof MultiColumnComponent;
ResponseWriter writer = context.getResponseWriter();
UIData data = (UIData) component;
int first = data.getFirst();
int rows = data.getRows();
for (int i = first, n = 0; n < rows; i++, n++)
{
data.setRowIndex(i);
if (!data.isRowAvailable())
{
break;
}
////////////////////////////////////
// TR
////////////////////////////////////
writer.startElement("tr", data);
Iterator iter = data.getChildren().iterator();
while (iter.hasNext())
{
UIComponent child = (UIComponent) iter.next();
if (child instanceof UIColumn)
{
writer.startElement("td", child);
writer.write("debug UIColumn");
RendererUtil.encodeRecursive(context, child);
writer.endElement("td");
}
else if (child instanceof UIData)
{
writer.write("debug UIData");
child.encodeBegin(context);
child.encodeChildren(context);
child.encodeEnd(context);
}
}
////////////////////////////////////
// /TR
////////////////////////////////////
writer.endElement("tr");
writer.write("\n");
}
}
示例3: encodeChildren
import javax.faces.component.UIData; //导入方法依赖的package包/类
/**
* We put all our processing in the encodeChildren method
* @param context
* @param component
* @throws IOException
*/
public void encodeChildren(FacesContext context, UIComponent component)
throws IOException
{
if (!component.isRendered())
{
return;
}
String clientId = null;
if (component.getId() != null &&
!component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
{
clientId = component.getClientId(context);
}
ResponseWriter writer = context.getResponseWriter();
if (clientId != null)
{
writer.startElement("span", component);
writer.writeAttribute("id", clientId, "id");
}
UIData data = (UIData) component;
int first = data.getFirst();
int rows = data.getRows();
// this is a special separator attribute, not supported by UIData
String separator = (String) RendererUtil.getAttribute(context, component, "separator");
if (separator==null) separator=" | ";
for (int i = first, n = 0; n < rows; i++, n++)
{
data.setRowIndex(i);
if (!data.isRowAvailable())
{
break;
}
// between any two iterations add separator if there is one
if (i!=first) writer.write(separator);
Iterator iter = data.getChildren().iterator();
while (iter.hasNext())
{
UIComponent column = (UIComponent) iter.next();
if (!(column instanceof UIColumn))
{
continue;
}
RendererUtil.encodeRecursive(context, column);
}
}
if (clientId != null)
{
writer.endElement("span");
}
}
示例4: decode
import javax.faces.component.UIData; //导入方法依赖的package包/类
public void decode(FacesContext context, UIComponent component)
{
String id = component.getClientId(context);
Map parameters = context.getExternalContext()
.getRequestParameterMap();
String response = (String) parameters.get(id);
String dataTableId = (String) get(context, component, "dataTableId");
Integer a = (Integer) get(context, component, "showpages");
int showpages = a == null ? 0 : a.intValue();
UIData data = (UIData) findComponent(context.getViewRoot(),
getId(dataTableId, id), context);
int first = data.getFirst();
int itemcount = data.getRowCount();
int pagesize = data.getRows();
if (pagesize <= 0)
{
pagesize = itemcount;
}
if (response == null)
{
first = 0;
}
else if ("<".equals(response))
{
first -= pagesize;
}
else if (">".equals(response))
{
first += pagesize;
}
else if ("<<".equals(response))
{
first -= pagesize * showpages;
}
else if (">>".equals(response))
{
first += pagesize * showpages;
}
else
{
int page = 0; // default if cannot be parsed
try
{
page = Integer.parseInt(response);
}
catch (NumberFormatException ex)
{
// do nothing, leave at zero
log.debug("do nothing, leave at zero");
}
first = (page - 1) * pagesize;
}
if (first + pagesize > itemcount)
{
first = itemcount - pagesize;
}
if (first < 0)
{
first = 0;
}
data.setFirst(first);
}
示例5: encodeChildren
import javax.faces.component.UIData; //导入方法依赖的package包/类
/**
* We put all our processing in the encodeChildren method
* @param context
* @param component
* @throws IOException
*/
public void encodeChildren(FacesContext context, UIComponent component)
throws IOException
{
if (!component.isRendered())
{
return;
}
String clientId = null;
if (component.getId() != null &&
!component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
{
clientId = component.getClientId(context);
}
ResponseWriter writer = context.getResponseWriter();
if (clientId != null)
{
writer.startElement("span", component);
writer.writeAttribute("id", clientId, "id");
}
UIData data = (UIData) component;
int first = data.getFirst();
int rows = data.getRows();
// this is a special separator attribute, not supported by UIData
String separator = (String) component.getAttributes().get("separator");
if (separator==null) separator="";
for (int i = first, n = 0; n < rows; i++, n++)
{
data.setRowIndex(i);
if (!data.isRowAvailable())
{
break;
}
// between any two iterations add separator if there is one
if (i!=first) writer.write(separator);
Iterator iter = data.getChildren().iterator();
while (iter.hasNext())
{
UIComponent column = (UIComponent) iter.next();
if (!(column instanceof UIColumn))
{
continue;
}
RendererUtil.encodeRecursive(context, column);
}
}
if (clientId != null)
{
writer.endElement("span");
}
}
示例6: clearAllInputs
import javax.faces.component.UIData; //导入方法依赖的package包/类
/**
* JSF 1.1 provides no way to cleanly discard input fields from a table when
* we know we won't use them. Ideally in such circumstances we'd specify an
* "immediate" action handler (to skip unnecessary validation checks and
* model updates), and then overwrite any existing values. However,
* JSF absolutely insists on keeping any existing input components as
* they are if validation and updating hasn't been done. When the table
* is re-rendered, all of the readonly portions of the columns will be
* refreshed from the backing bean, but the input fields will
* keep their now-incorrect values.
*
* <p>
* The easiest practical way to deal with this limitation is to avoid
* "immediate" actions when a table contains input fields, avoid side-effects
* from the bogus model updates, and stick the user with the inconvenience
* of unnecessary validation errors.
*
* <p>
* The only other solution we've found is to have the backing bean bind to
* the data table component (which just means storing a transient
* pointer to the UIData or HtmlDataTable when it's passed to the
* bean's "setTheDataTable" method), and then to have the action handler call
* this method to walk the table, look for UIInputs on each row, and
* perform the necessary magic on each to force reloading from the data model.
*
* <p>
* Usage:
* <pre>
* private transient HtmlDataTable dataTable;
* public HtmlDataTable getDataTable() {
* return dataTable;
* }
* public void setDataTable(HtmlDataTable dataTable) {
* this.dataTable = dataTable;
* }
* public void processImmediateIdSwitch(ActionEvent event) {
* // ... modify the current ID ...
* FacesUtil.clearAllInputs(dataTable);
* }
* </pre>
*/
public static void clearAllInputs(UIComponent component) {
if (log.isDebugEnabled()) log.debug("clearAllInputs " + component);
if (component instanceof UIInput) {
if (log.isDebugEnabled()) log.debug(" setValid, setValue, setLocalValueSet, setSubmittedValue");
UIInput uiInput = (UIInput)component;
uiInput.setValid(true);
uiInput.setValue(null);
uiInput.setLocalValueSet(false);
uiInput.setSubmittedValue(null);
} else if (component instanceof UIData) {
UIData dataTable = (UIData)component;
int first = dataTable.getFirst();
int rows = dataTable.getRows();
int last;
if (rows == 0) {
last = dataTable.getRowCount();
} else {
last = first + rows;
}
for (int rowIndex = first; rowIndex < last; rowIndex++) {
dataTable.setRowIndex(rowIndex);
if (dataTable.isRowAvailable()) {
for (Iterator iter = dataTable.getChildren().iterator(); iter.hasNext(); ) {
clearAllInputs((UIComponent)iter.next());
}
}
}
} else {
for (Iterator iter = component.getChildren().iterator(); iter.hasNext(); ) {
clearAllInputs((UIComponent)iter.next());
}
}
}