本文整理匯總了Java中javax.faces.component.UIComponent.getFacet方法的典型用法代碼示例。如果您正苦於以下問題:Java UIComponent.getFacet方法的具體用法?Java UIComponent.getFacet怎麽用?Java UIComponent.getFacet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.component.UIComponent
的用法示例。
在下文中一共展示了UIComponent.getFacet方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: encodeChildren
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
public void encodeChildren(FacesContext context,
UIComponent component) throws IOException
{
ResponseWriter out = context.getResponseWriter();
UIComponent month = component.getFacet("month");
month.encodeBegin(context);
month.encodeChildren(context);
month.encodeEnd(context);
out.writeText("\u00a0/\u00a0", null);
UIComponent day = component.getFacet("day");
day.encodeBegin(context);
day.encodeChildren(context);
day.encodeEnd(context);
out.writeText("\u00a0/\u00a0", null);
UIComponent year = component.getFacet("year");
year.encodeBegin(context);
year.encodeChildren(context);
year.encodeEnd(context);
}
示例2: isFlattenableCoreComponent
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
* Determine if we can flatten a core JSF component.
* @param component The component
* @return true if the component is a core JSF component and we can
* flatten it successfully.
*/
private static boolean isFlattenableCoreComponent(UIComponent component)
{
// Optimize the cases of UINamingContainer (<f:subview>) and UIPanel -
// we will treat these components as FlattenedComponents because they do not render
// any DOM.
// Also note that as of JSF 2.0, UINamingContainer components are built
// by f:subview, as well as composite components.
Class<? extends UIComponent> componentClass = component.getClass();
if (UINamingContainer.class == componentClass)
{
// Check to see if this component was created as a composite
// component, which we cannot flatten
return component.getFacet(UIComponent.COMPOSITE_FACET_NAME) == null;
}
// Note that JSF 2.0 creates UIPanel wrappers around multiple components
// inside of <f:facet>
return UIPanel.class == componentClass;
}
示例3: doStartTag
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
public int doStartTag() throws JspException
{
UIComponentClassicTagBase tag = UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext);
if (tag == null)
{
_LOG.warning("FACETREF_MUST_INSIDE_UICOMPONENT");
return SKIP_BODY;
}
UIComponent component = tag.getComponentInstance();
UIComponent region = _getRegionComponent(component);
if (region == null)
{
_LOG.warning("CANNOT_FIND_PARENT_COMPONENTREF");
return SKIP_BODY;
}
if (_facet != null)
{
UIComponent child = region.getFacet(_facet);
if (child != null)
{
_addChild(component, child);
// alert the region component that we moved one of its facets.
// This is so that it can restore the facet, during the next request,
// just in time to prevent the jsf jsp tag framework from
// getting confused:
ComponentRefTag.addRelocatedFacet(region, _facet, child);
}
}
else
{
_LOG.warning("FACETNAME_REQUIRED");
}
return SKIP_BODY;
}
示例4: _addChildren
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void _addChildren(FacesContext context, UIComponent component)
{
// If the components are already there, bail.
if (component.getFacet("month") != null)
return;
String id = component.getId();
if (id == null)
{
id = context.getViewRoot().createUniqueId();
component.setId(id);
}
Map<String, UIComponent> facets = component.getFacets();
facets.clear();
Date value = (Date) ((EditableValueHolder) component).getValue();
Calendar calendar = null;
if(value != null)
{
calendar = Calendar.getInstance();
calendar.setLenient(true);
calendar.setTime(value);
}
CoreInputText month = _createTwoDigitInput(context);
month.setShortDesc("Month");
month.setId(id + "_month");
LongRangeValidator monthRange = _createLongRangeValidator(context);
monthRange.setMinimum(1);
monthRange.setMaximum(12);
month.addValidator(monthRange);
if (value != null)
month.setValue(new Integer(calendar.get(Calendar.MONTH) + 1));
facets.put("month", month);
CoreInputText day = _createTwoDigitInput(context);
day.setShortDesc("Day");
day.setId(id + "_day");
LongRangeValidator dayRange = _createLongRangeValidator(context);
dayRange.setMinimum(1);
dayRange.setMaximum(31);
day.addValidator(dayRange);
if (value != null)
day.setValue(new Integer(calendar.get(Calendar.DAY_OF_MONTH)));
facets.put("day", day);
CoreInputText year = _createTwoDigitInput(context);
year.setShortDesc("Year");
year.setId(id + "_year");
if (value != null)
{
int yearValue = calendar.get(Calendar.YEAR) - 1900;
if (yearValue >= 100)
yearValue -= 100;
year.setValue(new Integer(yearValue));
}
facets.put("year", year);
}
示例5: getFacet
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
* Gets a facet, verifying that the facet should be rendered.
*/
static public UIComponent getFacet(
UIComponent component,
String name)
{
UIComponent facet = component.getFacet(name);
if ((facet == null) || !facet.isRendered())
return null;
return facet;
}
示例6: encodeAll
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
protected void encodeAll(
FacesContext context,
RenderingContext rc,
UIComponent comp,
FacesBean bean
) throws IOException
{
UIComponent busyFacet = comp.getFacet(CoreStatusIndicator.BUSY_FACET);
UIComponent readyFacet = comp.getFacet(CoreStatusIndicator.READY_FACET);
boolean iconMode = false;
Icon busyIcon = null;
Icon readyIcon = null;
if (busyFacet == null && readyFacet == null)
{
// Render icons only if no facet was specified.
busyIcon = rc.getIcon(SkinSelectors.AF_STATUS_INDICATOR_BUSY_ICON);
readyIcon = rc.getIcon(SkinSelectors.AF_STATUS_INDICATOR_READY_ICON);
if (busyIcon == null || readyIcon == null)
{
// Missing an icon and no faet was specified, log.
_LOG.warning("STATUS_INDICATOR_MISSING_ICONS");
return;
}
iconMode = true;
}
ResponseWriter rw = context.getResponseWriter();
String clientId = getClientId(context, comp);
// Renders root DOM
rw.startElement(XhtmlConstants.SPAN_ELEMENT, comp);
renderId(context, comp);
renderAllAttributes(context, rc, comp, bean);
// Renders ready DOM
rw.startElement(XhtmlConstants.SPAN_ELEMENT, null);
rw.writeAttribute(XhtmlConstants.ID_ATTRIBUTE, clientId + "::ready", null);
if (iconMode)
{
_renderIcon(context, rc, readyIcon, "af_statusIndicator.READY");
}
else
{
_renderFacet(context, rc, readyFacet,
SkinSelectors.AF_STATUS_INDICATOR_READY_STYLE);
}
rw.endElement(XhtmlConstants.SPAN_ELEMENT);
// Renders busy DOM
rw.startElement(XhtmlConstants.SPAN_ELEMENT, null);
rw.writeAttribute(XhtmlConstants.ID_ATTRIBUTE, clientId + "::busy", null);
rw.writeAttribute(XhtmlConstants.STYLE_ATTRIBUTE, "display:none", null);
if (iconMode)
{
_renderIcon(context, rc, busyIcon, "af_statusIndicator.BUSY");
}
else
{
_renderFacet(context, rc, busyFacet,
SkinSelectors.AF_STATUS_INDICATOR_BUSY_STYLE);
}
rw.endElement(XhtmlConstants.SPAN_ELEMENT);
rw.startElement(XhtmlConstants.SCRIPT_ELEMENT, null);
renderScriptTypeAttribute(context, rc);
rw.writeText("TrStatusIndicator._register(\"" + clientId + "\");", null);
rw.endElement(XhtmlConstants.SCRIPT_ELEMENT);
rw.endElement(XhtmlConstants.SPAN_ELEMENT);
}
示例7: getConvertedValue
import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
public Object getConvertedValue(
FacesContext context,
UIComponent component,
Object submittedValue)
{
EditableValueHolder monthComp = (EditableValueHolder) component.getFacet("month");
EditableValueHolder yearComp = (EditableValueHolder) component.getFacet("year");
EditableValueHolder dayComp = (EditableValueHolder) component.getFacet("day");
if (!monthComp.isValid() ||
!yearComp.isValid() ||
!dayComp.isValid())
{
// =-=AEW What to do????????
//setValid(false);
return null;
}
int year = ((Number) yearComp.getValue()).intValue();
// We'll be 1970 - 2069. Good enough for a demo.
if (year < 70)
year += 100;
int month = ((Number) monthComp.getValue()).intValue() - 1;
int day = ((Number) dayComp.getValue()).intValue();
Date oldValue = (Date) ((EditableValueHolder) component).getValue();
//Date newValue = (Date) oldValue.clone();
Calendar calendar = Calendar.getInstance();
calendar.setLenient(true);
calendar.setTime(oldValue);
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, day);
// Invalid day given the month
if (day != calendar.get(Calendar.DAY_OF_MONTH))
{
int numberOfDaysInMonth = day - calendar.get(Calendar.DAY_OF_MONTH);
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Invalid date.",
"This month only has " + numberOfDaysInMonth + " days!");
throw new ConverterException(message);
}
return calendar.getTime();
}