本文整理匯總了Java中javax.faces.component.UIViewRoot.findComponent方法的典型用法代碼示例。如果您正苦於以下問題:Java UIViewRoot.findComponent方法的具體用法?Java UIViewRoot.findComponent怎麽用?Java UIViewRoot.findComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.component.UIViewRoot
的用法示例。
在下文中一共展示了UIViewRoot.findComponent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTableSectionId
import javax.faces.component.UIViewRoot; //導入方法依賴的package包/類
/**
* Ids of fields inside tables look like <code>tableId:rowNr:fieldId</code>.
* So we try to cut the fieldId and the rowNr parts to get the table id and
* then check if it is inside a section and return the section id.
*
* @param clientId
* the id of the field inside of a table
* @param root
* the {@link UIViewRoot}
* @return the section id or <code>null</code>
*/
private String getTableSectionId(String clientId, UIViewRoot root) {
if (!clientId.contains(":")) {
return null;
}
// cut the field id
clientId = clientId.substring(0, clientId.lastIndexOf(':'));
if (!clientId.contains(":")) {
return null;
}
// cut the row number - we should have the table id
clientId = clientId.substring(0, clientId.lastIndexOf(':'));
UIComponent comp = root.findComponent(clientId);
if (comp != null) {
return getSectionId(comp);
}
return null;
}
示例2: getComponentValue
import javax.faces.component.UIViewRoot; //導入方法依賴的package包/類
public static String getComponentValue(String componentId) {
String value = null;
UIViewRoot root = getCurrentInstance().getViewRoot();
UIComponent component = root.findComponent(componentId);
if (component != null) {
Object o = component.getValueExpression("value").getValue(getCurrentInstance().getELContext());
value = (String) o;
}
return value;
}
示例3: removeComponent
import javax.faces.component.UIViewRoot; //導入方法依賴的package包/類
public static void removeComponent(String componentId) {
UIViewRoot root = getCurrentInstance().getViewRoot();
UIComponent component = root.findComponent(componentId);
if (component != null) {
UIComponent parent = component.getParent();
parent.getChildren().remove(component);
}
}
示例4: getComponent
import javax.faces.component.UIViewRoot; //導入方法依賴的package包/類
/**
* This method will use a calculated "component path" to walk down to the <code>UIComponent</code>
* that is referenced by this class. If the component can not be found, the <code>getComponent()</code>
* will return <code>null</code>.
*
* @return the referenced <code>UIComponent</code> or <code>null</code> if it can not be found.
* @throws IllegalStateException if the component used to create the
* ComponentReference is not in the component tree or does <b>not</b> have an <code>Id</code>
* @see ComponentReference#newUIComponentReference(UIComponent)
*/
@SuppressWarnings("unchecked")
public final T getComponent()
{
// get the scopedId, calculating it if necessary
String scopedId = getScopedId();
UIComponent foundComponent = null;
// In order to find the component with its
// calculated path, we need to start at the ViewRoot;
UIViewRoot root = FacesContext.getCurrentInstance().getViewRoot();
List<Object> componentPath = _componentPath;
if (componentPath != null)
{
// Walk down the component tree, to the component we are looking for.
// We start at the ViewRoot and use the previous calculated "component path"
foundComponent = _walkPathToComponent(root, componentPath);
}
// Check if we really found it with the previously created "component path"
if (foundComponent == null || (!getComponentId().equals(foundComponent.getId())))
{
// OK, we were not lucky with the calculated "component path", let's
// see if we can find it by using the "scoped ID" and the regular
// findComponent();
foundComponent = root.findComponent(scopedId);
// was the regular findComponent() successful ?
if (foundComponent != null)
{
// OK, now let's rebuild the path
_componentPath = calculateComponentPath(foundComponent);
}
}
return (T)foundComponent;
}
示例5: teste
import javax.faces.component.UIViewRoot; //導入方法依賴的package包/類
public void teste() {
FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot viewRoot = context.getViewRoot();
DataTable dataTable = (DataTable) viewRoot.findComponent("Rel:tabelaRelatorio");
dataTable.setValue(null);
dataTable.setColumns(null);
Validacao.AtualizarCompoente("Rel", "tabelaRelatorio");
String tipoRelatorio = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("relatorio");
relatorio.setTipoRelatorio(tipoRelatorio);
}