Java Code Examples for javax.faces.component.UIComponent

The following are top voted examples for showing how to use javax.faces.component.UIComponent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: myfaces-trinidad   File: SimpleSelectOneChoiceRenderer.java   Source Code and License 7 votes vote down vote up
/**
 * In Internet Explorer, handle autosubmit.
 */
@Override
protected String getOnblur(
  UIComponent component,
  FacesBean   bean)
{
  RenderingContext rc = RenderingContext.getCurrentInstance();
  String onblur = super.getOnblur(component, bean);

  //PH: onblur should be included only for desktop IE since PIE and
  //IE mobile do not support onblur on a select component
  if (isIE(rc) &&  isDesktop(rc) && isAutoSubmit(component, bean))
  {
    String auto = getAutoSubmitScript(rc, component, bean);
    // See getOnclick()
    auto = _IE_ACTION_HANDLER_PREFIX + auto;
    onblur = XhtmlUtils.getChainedJS(onblur, auto, true);
  }

  return onblur;
}
 
Example 2
Project: oscm   File: JSFUtils.java   Source Code and License 7 votes vote down vote up
/**
 * Reset the values of all UIInput children. This might be necessary after a
 * validation error to successfully process an AJAX request. See [Bug 5449]
 * and http://wiki.apache.org/myfaces/ClearInputComponents
 * 
 * @param uiComponent
 *            the root component to be processed.
 */
public static void resetUIInputChildren(UIComponent uiComponent) {
    if (uiComponent != null) {
        List<UIComponent> children = uiComponent.getChildren();
        for (UIComponent child : children) {
            if (child instanceof UIInput) {
                UIInput uiInput = (UIInput) child;
                uiInput.setSubmittedValue(null);
                uiInput.setValue(null);
                uiInput.setLocalValueSet(false);
            } else {
                resetUIInputChildren(child);
            }
        }
    }
}
 
Example 3
Project: myfaces-trinidad   File: HiddenLabelUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Outputs a hidden label.
 * @param component 
 */
static public void outputHiddenLabel(
  UIXRenderingContext context,
  String           id,
  Object           text, 
  UIComponent component
  ) throws IOException
{
  if (!XhtmlLafRenderer.isInaccessibleMode(context) &&
      (text != null) &&
      (id   != null))
  {
    if (!id.equals(context.getProperty(UIConstants.MARLIN_NAMESPACE,
                                       _LABEL_KEY)))
    {
      ResponseWriter writer = context.getResponseWriter();
      writer.startElement("label", component);
      writer.writeAttribute("for", id, null);
      XhtmlLafRenderer.renderStyleClassAttribute(context,
                                                 _HIDDEN_LABEL_CLASS);
      writer.writeText(text, null);
      writer.endElement("label");
    }
  }
}
 
Example 4
Project: oscm   File: ManageOperatorRevenueShareCtrlTest.java   Source Code and License 6 votes vote down vote up
@Test
public void templateChanged_toSameValue() {
    // given
    ValueChangeEvent event = new ValueChangeEvent(mock(UIComponent.class),
            Long.valueOf(101L), Long.valueOf(101L));
    ManageOperatorRevenueShareModel model = new ManageOperatorRevenueShareModel();
    model.setSelectedTemplateKey(101L);
    ctrl.setModel(spy(model));

    // when
    ctrl.templateChanged(event);

    // then
    assertEquals(101L, ctrl.getModel().getSelectedTemplateKey());
    verify(ctrl.getModel(), times(0)).setSelectedTemplateKey(eq(101L));
}
 
Example 5
Project: ctsms   File: IDVOConverter.java   Source Code and License 6 votes vote down vote up
@Override
public String getAsString(FacesContext facesContext, UIComponent component, Object value) {
	if (value == null) {
		return CommonUtil.NO_SELECTION_VALUE;
	} else if (value instanceof String) {
		if (CommonUtil.NO_SELECTION_VALUE.equals(value)) {
			return CommonUtil.NO_SELECTION_VALUE;
		} else {
			return WebUtil.stringToLong((String) value).toString();
		}
	} else if (value instanceof IDVO) {
		return ((IDVO) value).getId().toString();
	} else {
		return CommonUtil.NO_SELECTION_VALUE;
	}
}
 
Example 6
Project: ol3jsf   File: InputVectorLayer.java   Source Code and License 6 votes vote down vote up
@Override
public void encodeAll(FacesContext context) throws IOException {
	ResponseWriter writer = context.getResponseWriter();
	String features = ComponentUtils.getValueToRender(context, this);
	UIComponent parent = this;

	while (!(parent instanceof Map)) {
		parent = parent.getParent();
	}

	Map mapComponent = (Map) parent;
	String mapVar = mapComponent.getJsVariable();

	if (features == null || features.length() == 0) {
		features = "[]";
	}

	writer.write("var vector = new ol.layer.Vector({" + "  source: new ol.source.Vector(), " + "  style: new ol.style.Style({" + "	   fill: new ol.style.Fill({"
			+ "	     color: 'rgba(50,30,230, 0.3)'" + "	   })," + "	   stroke: new ol.style.Stroke({" + "	     color: 'rgba(50,25,180, 1)'," + "		 width: 2" + "	   })" + "  })" + "});\n");

	writer.write(mapVar + ".addLayer(vector);\n");
	writer.write("vector.getSource().addFeatures(" + features + ");\n");
}
 
Example 7
Project: myfaces-trinidad   File: CoreRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * <p>
 * Called when visiting the CoreRenderer's component during optimized partial page encoding so
 * that the CoreRenderer can modify what is actually encoded.  For example tab controls often
 * render the tabs for the ShowDetailItems in the tab bar before delegating to the
 * disclosed ShowDetailItem to render the tab content.  As a result, the tab control
 * needs to encode its tab bar if any of its ShowDetailItems are partial targets so that
 * the tab labels, for example, are up-to-date.
 * </p>
 * <p>
 * The default implementation calls the VisitCallback and returns its result if this UIXComponent
 * is a partial target of the current encoding.
 * </p>
 * @param visitContext VisitContext to pass to the VisitCallback
 * @param partialContext PartialPageContext for the current partial encoding
 * @param component The component for the CoreRenderer to visit
 * @param callback VisitCallback to call if this component is a partial target
 * @return The VisitResult controlling continued iteration of the visit.
 */
public VisitResult partialEncodeVisit(
  VisitContext       visitContext,
  PartialPageContext partialContext,
  UIComponent        component,
  VisitCallback      callback)
{
  if (partialContext.isPossiblePartialTarget(component.getId()) &&
      partialContext.isPartialTarget(component.getClientId(visitContext.getFacesContext())))
  {
    // visit the component instance
    return callback.visit(visitContext, component);
  }
  else
  {
    // Not visiting this component, but allow visit to
    // continue into this subtree in case we've got
    // visit targets there.
    return VisitResult.ACCEPT;
  }
}
 
Example 8
Project: myfaces-trinidad   File: ColumnGroupRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * @return the state of the sorting after the page submition
 */
private String findSortState(
  int         sortability,
  UIComponent component,
  FacesBean   bean)
{
  String state;
  if (sortability == SORT_ASCENDING)
  {
    state = XhtmlConstants.SORTABLE_ASCENDING;
  }
  else if (sortability == SORT_DESCENDING)
  {
    state = XhtmlConstants.SORTABLE_DESCENDING;
  }
  else if ("descending".equals(getDefaultSortOrder(component, bean)))
  {
    state = XhtmlConstants.SORTABLE_ASCENDING;
  }
  else
  {
    state = "";
  }

  return state;
}
 
Example 9
Project: myfaces-trinidad   File: MediaRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * Returns the lowercase extension of any source URL
 */
private String _getSourceExtension(
  UIComponent component,
  FacesBean   bean)
{
  String sourceURLString = getSource(component, bean);

  if (sourceURLString != null)
  {
    int extensionIndex = sourceURLString.lastIndexOf('.');

    if ((extensionIndex != -1) &&
        (extensionIndex != sourceURLString.length() -1))
    {
      return sourceURLString.substring(extensionIndex + 1).toLowerCase();
    }
  }

  // no extension
  return null;
}
 
Example 10
Project: myfaces-trinidad   File: ColumnGroupRenderer.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void _renderChildren(
  FacesContext context,
  UIComponent  component,
  NodeData     parentNode
  ) throws IOException
{
  int i = 0;
  for(UIComponent child : (List<UIComponent>)component.getChildren())
  {
    if (child.isRendered())
    {
      // Tell the parent node - if there is one - which child we're rendering
      if (parentNode != null)
      {
        parentNode.currentChild = i;
      }

      encodeChild(context, child);
    }

    i++;
  }
}
 
Example 11
Project: oscm   File: LongValidator.java   Source Code and License 6 votes vote down vote up
/**
 * Parses the specified string into a long integer.
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to parse
 * @throws ValidatorException
 *             if the specified string could not be parsed into a valid long
 *             integer.
 */
public static long parse(FacesContext context, UIComponent uiComponent,
        String value) throws ValidatorException {
    if (!GenericValidator.isLong(value)) {
        Object[] args = null;
        String label = JSFUtils.getLabel(uiComponent);
        if (label != null) {
            args = new Object[] { label };
        }
        ValidationException e = new ValidationException(
                ValidationException.ReasonEnum.LONG, label, null);
        String message = JSFUtils.getText(e.getMessageKey(), args, context);
        throw getException(message);
    }
    return Long.parseLong(value);
}
 
Example 12
Project: myfaces-trinidad   File: NumberConverter.java   Source Code and License 6 votes vote down vote up
private String _getTrNumberConverter(
  FacesContext context,
  UIComponent  component,
  Map<?, ?>    messages)
{
  StringBuilder outBuffer = new StringBuilder(250);
  outBuffer.append("new TrNumberConverter(");

  Object[] params = _getClientConstructorParams(context, messages);
  for (int i = 0; i < params.length; i++)
  {
    try
    {
      JsonUtils.writeObject(outBuffer, params[i], false); 
    } 
    catch (Exception e)
    {
      outBuffer.append("null");
    }
    if (i < params.length-1)
      outBuffer.append(',');
  }
  outBuffer.append(')');
  return outBuffer.toString();
}
 
Example 13
Project: myfaces-trinidad   File: UIXEditableValueTemplate.java   Source Code and License 6 votes vote down vote up
/**
 * Executes validation logic.
 */
private void _executeValidate(FacesContext context)
{
  Application application = context.getApplication();
  application.publishEvent(context, PreValidateEvent.class, UIComponent.class, this);
  try
  {
    validate(context);
  }
  catch (RuntimeException e)
  {
    context.renderResponse();
    throw e;
  }
  finally
  {
    application.publishEvent(context, PostValidateEvent.class, UIComponent.class, this);
  }

  if (!isValid())
  {
    context.renderResponse();
  }
}
 
Example 14
Project: myfaces-trinidad   File: ChangeBean.java   Source Code and License 6 votes vote down vote up
/**
 * Removes a pair of children, based on some characteristic of the
 *  event source.
 */
public void removeChildren(ActionEvent event)
{
  UIComponent eventSource = event.getComponent();
  UIComponent uic = eventSource.findComponent("pg1");
  int numChildren = uic.getChildCount();
  if (numChildren == 0)
    return;
  String eventSourceId = eventSource.getId();    
  if (eventSourceId.equals("cb2"))
  {
    _removeChild(uic, "sic1");
    _removeChild(uic, "cc1");
  }
  else if (eventSourceId.equals("cb3"))
  {
    _removeChild(uic, "cd1");
    _removeChild(uic, "sid1");
  }
}
 
Example 15
Project: myfaces-trinidad   File: IconRenderer.java   Source Code and License 6 votes vote down vote up
private Map<String, Object> _getNodeAttributeMap(
  FacesContext context,
  UIComponent  comp,
  FacesBean    bean,
  boolean      embed)
{
  Map<String, Object> attrs = null;
  attrs = new ArrayMap<String, Object>(1);

  attrs.put(Icon.SHORT_DESC_KEY, getShortDesc(comp, bean));
  attrs.put(Icon.STYLE_CLASS_KEY, getStyleClass(comp, bean));

  if (embed)
  {
    attrs.put(Icon.EMBEDDED_KEY, Boolean.TRUE);
  }
  else
  {
    attrs.put(Icon.ID_KEY, getClientId(context, comp));
  }

  return attrs;
}
 
Example 16
Project: myfaces-trinidad   File: SeparatorRenderer.java   Source Code and License 6 votes vote down vote up
@Override
protected void renderAllAttributes(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  ResponseWriter rw = context.getResponseWriter();

  renderAllAttributes(context, rc, component, bean, false);
  renderStyleAttributes(context, rc, component, bean);

  // Old PDA renderer rule
  if (isPDA(rc))
    rw.writeAttribute("size", "1", null);
}
 
Example 17
Project: myfaces-trinidad   File: DesktopPanelPageHeaderRenderer.java   Source Code and License 6 votes vote down vote up
@Override
protected void encodeAll(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{

 // =-=AEW We don't have any real agent switching
  if (!isDesktop(rc))
  {
    delegateRenderer(context, rc, component, bean, _pdaRenderer);
  }
  else
  {
    encodeAllDesktop(context, rc, component, bean);
  }

}
 
Example 18
Project: myfaces-trinidad   File: DoubleConverter.java   Source Code and License 6 votes vote down vote up
@Override
public Object getAsObject(
  FacesContext context, 
  UIComponent component,
  String value) 
{
  try
  {
    return super.getAsObject(context, component, value);
  }
  catch(ConverterException ce)
  {
    throw ConverterUtils.createConverterException(context, 
                                                       component,
                                                       CONVERT_MESSAGE_ID, 
                                                       value);                                                      
  }     
  
}
 
Example 19
Project: myfaces-trinidad   File: UIXNavigationLevelTemplate.java   Source Code and License 6 votes vote down vote up
private boolean _visitChildrenIterating(
  VisitContext  visitContext,
  VisitCallback callback)
{
  boolean done = visitData(visitContext, callback);

  if (!done)
  {
    // process the children
    int childCount = getChildCount();
    if (childCount > 0)
    {
      for (UIComponent child : getChildren())
      {
        done = UIXComponent.visitTree(visitContext, child, callback);

        if (done)
          break;
      }
    }
  }

  return done;
}
 
Example 20
Project: myfaces-trinidad   File: ShowOneUtils.java   Source Code and License 6 votes vote down vote up
/**
 *  Creates encoded partial targets for UIComponent.
 *  Adds the compId to the list of partial targets available in component
 *  attribute map.
 *
 * @param component the UIComponent object
 * @param compId the id to be added to already available partial targets
 * @return String encoded partialTarget string
 */
static String getEncodedPartialTargets(UIComponent component, String compId)
{
  String[] pprTargets =
    (String []) component.getAttributes().get("partialTargets");
  String encodedPartialTargets = null;
  if ( (pprTargets != null) && (pprTargets.length > 0)  )
  {
    String[] pprTargetsNew = new String[pprTargets.length + 1];
    System.arraycopy(pprTargets, 0, pprTargetsNew, 0, pprTargets.length);
    pprTargetsNew[pprTargets.length] = compId;
    encodedPartialTargets =
      PartialPageRendererUtils.encodePartialTargets(pprTargetsNew);
  }
  else
  {
    encodedPartialTargets =
      PartialPageRendererUtils.encodePartialTargets(new String[] {compId});
  }
  return encodedPartialTargets;
}
 
Example 21
Project: myfaces-trinidad   File: OutputLabelRenderer.java   Source Code and License 5 votes vote down vote up
protected boolean getShowRequired(
  UIComponent component,
  FacesBean   bean)
{
  Object o = bean.getProperty(_showRequiredKey);
  if (o == null)
    o = _showRequiredKey.getDefault();

  return Boolean.TRUE.equals(o);
}
 
Example 22
Project: myfaces-trinidad   File: NavigationPaneRenderer.java   Source Code and License 5 votes vote down vote up
protected boolean getDisabled(
  UIComponent component,
  FacesBean   bean)
{
  Object o = bean.getProperty(_disabledKey);
  if (o == null)
    o = _disabledKey.getDefault();
  return Boolean.TRUE.equals(o);
}
 
Example 23
Project: myfaces-trinidad   File: PanelBorderLayoutRenderer.java   Source Code and License 5 votes vote down vote up
protected String getEndWidth(
  UIComponent component,
  FacesBean   bean)
{
  return ComponentUtils.resolveString(bean.getProperty(_endWidthKey),
           (String)_endWidthKey.getDefault());
}
 
Example 24
Project: myfaces-trinidad   File: CellFormatRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected void encodeAll(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  ResponseWriter rw = context.getResponseWriter();
  String element = isHeader(component, bean) ? "th" : "td";

  rw.startElement(element, component);
  renderId(context, component);
  renderAllAttributes(context, rc, component, bean);
  renderHAlign(context, rc, getHalign(component, bean));
  rw.writeAttribute("valign", getValign(component, bean), "valign");
  rw.writeAttribute("abbr", getShortText(component, bean), "shortText");
  rw.writeAttribute("headers", getHeaders(component, bean), "headers");
  rw.writeAttribute("width", getWidth(component, bean), "width");
  rw.writeAttribute("height", getHeight(component, bean), "height");

  int colspan = getColumnSpan(component, bean);
  if (colspan > 1)
    rw.writeAttribute("colspan", colspan, "columnSpan");
  int rowspan = getRowSpan(component, bean);
  if (rowspan > 1)
    rw.writeAttribute("rowspan", rowspan, "rowSpan");
  if (isWrappingDisabled(component, bean))
  {
    // On PDA browser where the width is limited, nowrap will not be set.
    if (isDesktop(rc))
    {
      rw.writeAttribute("nowrap", Boolean.TRUE, "wrappingDisabled");
    }
  }

  encodeAllChildren(context, component);

  rw.endElement(element);
}
 
Example 25
Project: myfaces-trinidad   File: XhtmlUtils.java   Source Code and License 5 votes vote down vote up
/**
 * Skip over pure iteration components to find a "structural" parent.
 * This code is not guaranteed to work, but will work well enough.
 * @return a structural parent, or null if none exists
 */
static public UIComponent getStructuralParent(UIComponent component)
{
  while (true)
  {
    component = component.getParent();
    if (component == null)
      return null;

    if (_NON_STRUCTURAL_COMPONENT_FAMILIES.contains(component.getFamily()))
      continue;

    return component;
  }
}
 
Example 26
Project: myfaces-trinidad   File: SimpleInputTextRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected String getOnchange(
  UIComponent component,
  FacesBean   bean)
{
  String onchange = super.getOnchange(component, bean);
  if (isAutoSubmit(component, bean))
  {
    RenderingContext rc = RenderingContext.getCurrentInstance();
    String source = LabelAndMessageRenderer.__getCachedClientId(rc);
    boolean immediate = isImmediate(component, bean);
    String auto = AutoSubmitUtils.getSubmitScript(rc, source, XhtmlConstants.AUTOSUBMIT_EVENT,
                    immediate);
    if (onchange == null)
      onchange = auto;
    else if (auto != null)
      onchange = XhtmlUtils.getChainedJS(onchange, auto, true);
  }

  if (isTextArea(component, bean))
  {
    Number maxLength = getMaximumLength(component, bean);
    if (maxLength != null && maxLength.intValue()> 0)
    {
      onchange = _getMaxLengthFunction(onchange,
                                       maxLength.intValue());
    }
  }

  return onchange;
}
 
Example 27
Project: myfaces-trinidad   File: SimpleSelectOneListboxRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected String getUnselectedLabel(
  UIComponent component,
  FacesBean   bean)
{
  return toString(bean.getProperty(_unselectedLabelKey));
}
 
Example 28
Project: myfaces-trinidad   File: SimpleInputFileRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected Object getSubmittedValue(
  FacesContext context,
  UIComponent  component,
  String       clientId)
{
  // Since we override getSubmittedValue() entirely,
  // detect auto submit manually
  detectAutoSubmit(context, component, clientId);

  Object result = null;
  UploadedFile file = null;

  UploadedFiles files = UploadedFiles.getUploadedFiles(context);
  if (files != null)
  {
    file = files.getUploadedFile(clientId);
  }

  // If we couldn't find a file (e.g. does not exist OR the file is empty),
  // return "FALSE" to indicate that...
  // the file upload *was* available, but didn't upload a file
  // this time.
  if (file == null || file.getLength() == 0)
    result = Boolean.FALSE;
  else
    result = file;

  return result;
}
 
Example 29
Project: myfaces-trinidad   File: InputLabelAndMessageRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected void renderFieldCellContents(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  delegateRenderer(context, rc, component, bean, getFormInputRenderer());
}
 
Example 30
Project: myfaces-trinidad   File: TreeRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected void encodeAll(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  // Since Train is a naming container, we can be more
  // efficient about skipping its children
  if (!PartialPageUtils.containsPprTargets(rc,
                                           component,
                                           getClientId(context, component)))
  {
    return;
  }

  UIXHierarchy tree = (UIXHierarchy) component;
  TreeUtils.expandFocusRowKey((UIXTree) component);

  Object oldPath = tree.getRowKey();
  try
  {
    boolean continueRendering = setInitialPath(tree, bean);
    if (!continueRendering)
      return;

    _renderContent(context, rc, tree, bean);
  }
  finally
  {
    tree.setRowKey(oldPath);
  }
}
 
Example 31
Project: myfaces-trinidad   File: FormInputRenderer.java   Source Code and License 5 votes vote down vote up
protected void renderDisabledAttribute(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{

  if (getDisabled(component, bean))
  {
    context.getResponseWriter().writeAttribute("disabled",
                                               Boolean.TRUE,
                                               "disabled");
  }
}
 
Example 32
Project: myfaces-trinidad   File: LabelAndMessageRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected String getForId(
  FacesContext context,
  UIComponent  component,
  FacesBean    bean)
{
  return getLabelFor(context,
                     RenderingContext.getCurrentInstance(),
                     component,
                     bean);
}
 
Example 33
Project: myfaces-trinidad   File: PanelBorderLayoutRenderer.java   Source Code and License 5 votes vote down vote up
/**
 * @see org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlRenderer#getDefaultStyleClass
 */
@Override
protected String getDefaultStyleClass(
  UIComponent component,
  FacesBean   bean)
{
  return "positioned".equals(getLayout(component, bean)) ?
    SkinSelectors.AF_PANEL_BORDER_POSITIONED_ROOT_STYLE_CLASS : null;
}
 
Example 34
Project: myfaces-trinidad   File: DetailColumnRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected boolean getNoWrap(
  UIComponent component,
  FacesBean   bean)
{
  return true;
}
 
Example 35
Project: myfaces-trinidad   File: FastRenderer2.java   Source Code and License 5 votes vote down vote up
protected int getTruncateAt(
  UIComponent  component,
  FacesBean    bean)
{
  Object o = bean.getProperty(_truncateAtKey);
  if (o == null)
    o = _truncateAtKey.getDefault();

  assert(o != null);
  return ((Number) o).intValue();
}
 
Example 36
Project: oscm   File: PSPConverter.java   Source Code and License 5 votes vote down vote up
@Override
public Object getAsObject(FacesContext context, UIComponent component,
                          String value) {
    VOPSP retVal = null;
    for (VOPSP vopsp : oob.getPSPs()) {
        if ((Long.valueOf(vopsp.getKey()).toString().equals(value))) {
            retVal = vopsp;
        }
    }
    return retVal;
}
 
Example 37
Project: myfaces-trinidad   File: SingleStepButtonBarRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected boolean getImmediate(
  UIComponent component,
  FacesBean   bean)
{
  return !_next;
}
 
Example 38
Project: myfaces-trinidad   File: OutputLabelRenderer.java   Source Code and License 5 votes vote down vote up
protected boolean isLabelTagNeeded(
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean,
  String           forId,
  int              accessKeyIndex
)
{
  return (((forId != null) &&
          !isInaccessibleMode(rc)) ||
          (accessKeyIndex >= 0));
}
 
Example 39
Project: oscm   File: DurationConverterTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testGetAsStringEmpty() {
    UIComponent component = ConverterTestHelper.getComponent(false, null,
            null, "duration");
    String result = converter.getAsString(context, component, "");
    Assert.assertNull(result);
}
 
Example 40
Project: myfaces-trinidad   File: SelectManyShuttleRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected boolean getReadOnly(
  FacesContext context,
  UIComponent  component,
  FacesBean    bean)
{
  return false;
}
 
Example 41
Project: myfaces-trinidad   File: ComponentDefTag.java   Source Code and License 5 votes vote down vote up
@Override
public int doStartTag() throws JspException
{
  UIComponentClassicTagBase tag = UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext);
  if (tag == null)
  {
    throw new JspException(_LOG.getMessage(
      "COMPOENENTDEF_CANNOT_RUN_AS_STANDALONE"));
  }

  // Only run on the first time the tag executes
  if (tag.getCreated())
  {
    UIComponent component = tag.getComponentInstance();
    if (!(component instanceof UIXComponentRef))
    {
      throw new JspException(_LOG.getMessage(
        "COMPONENTDEF_MUST_BE_INCLUDED_AS_CHILD_OF"));
    }

    if (_var != null)
    {
      ((UIXComponentRef) component).setVar(_var);
    }
  }

  return EVAL_PAGE;
}
 
Example 42
Project: myfaces-trinidad   File: ScriptBufferingResponseWriter.java   Source Code and License 5 votes vote down vote up
public void startElement(String name, UIComponent component)
   throws IOException
{
  if (_enabled && "script".equals(name))
  {
    _inScript = true;
  }
  else
  {
    super.startElement(name, component);
  }
}
 
Example 43
Project: myfaces-trinidad   File: GoButtonRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected String getDefaultStyleClass(
  UIComponent component,
  FacesBean   bean)
{
  return SkinSelectors.AF_GO_BUTTON_STYLE_CLASS;
}
 
Example 44
Project: myfaces-trinidad   File: CoreFormTest.java   Source Code and License 5 votes vote down vote up
@Override
protected boolean willChildrenBeProcessed(UIComponent component)
{
  if (!component.isRendered())
    return false;

  if (component instanceof TestForm)
    return ((TestForm) component).getWillBeSubmitted();
  else
    return ((CoreForm) component).isSubmitted();
}
 
Example 45
Project: oscm   File: POServiceConverterTest.java   Source Code and License 5 votes vote down vote up
/**
 * Test for getting value.
 * 
 * @throws ParseException
 */
@Test
public void testGetAsObject() throws ConverterException, ParseException {
    UIComponent component = getComponent();
    POService actual = (POService) converter.getAsObject(context,
            component, poServiceAsString);
    Assert.assertEquals(actual.getKey(), 10001);
    Assert.assertEquals(actual.getPictureUrl(),
            "/image?type=SERVICE_IMAGE&amp;serviceKey=10001");
    Assert.assertEquals(actual.getProviderName(), "Fujitsu");
    Assert.assertEquals(actual.getServiceName(),
            "Hello Kitty November 6.66 1234:");
    Assert.assertEquals(actual.getStatusSymbol(), "status_NOT_ACTIVE");
    Assert.assertEquals(actual.getVersion(), 5);
}
 
Example 46
Project: myfaces-trinidad   File: MessageBoxRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected void renderEventHandlers(
  FacesContext context,
  UIComponent  component,
  FacesBean    bean
  ) throws IOException
{
  // Prevent HeaderRenderer from re-rendering event handlers
}
 
Example 47
Project: myfaces-trinidad   File: SimpleInputNumberSpinboxRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected String getRootStyleClass(
  UIComponent component,
  FacesBean   bean)
{
  return "af|inputNumberSpinbox";
}
 
Example 48
Project: myfaces-trinidad   File: PanelLabelAndMessageRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected void renderFieldCellContents(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  // The structure of this part of the DOM looks like this:
  // +------------------+-----------+
  // | indexed children | end facet |
  // +------------------+-----------+
  ResponseWriter rw = context.getResponseWriter();
  rw.startElement("table", component);
  OutputUtils.renderLayoutTableAttributes(context, rc, "0", null/*width*/);

  UIComponent end = getFacet(component, CorePanelLabelAndMessage.END_FACET);

  // Build the main row:
  rw.startElement("tr", null);
  rw.startElement("td", null);
  encodeAllChildren(context, component);
  rw.endElement("td");

  // For narrow-screen PDAs, End facet is rendered vertically
  // below the Help facet. So skip the End facet rendering here.
  if (end != null && !supportsNarrowScreen(rc))
  {
    rw.startElement("td", null);
    // =-= mcc TODO apply className for "af|panelLabelAndMessage::end-facet"
    // renderStyleClass(context, arc, ...);
    //apply className for "af|panelLabelAndMessage::help-facet"
    encodeChild(context, end);
    rw.endElement("td");
  }

  rw.endElement("tr");
  rw.endElement("table");
}
 
Example 49
Project: myfaces-trinidad   File: MessageRenderer.java   Source Code and License 5 votes vote down vote up
protected String getMessageType(
  UIComponent component,
  FacesBean   bean)
{
  // We're used in some composite circumstances where
  // the message type is always derived from the presence
  // of a message, and cannot be overridden
  if (_messageTypeKey == null)
    return null;

  return toString(bean.getProperty(_messageTypeKey));
}
 
Example 50
Project: myfaces-trinidad   File: PanelBorderLayoutRenderer.java   Source Code and License 5 votes vote down vote up
protected String getinnerTopHeight(
  UIComponent component,
  FacesBean   bean)
{
  return ComponentUtils.resolveString(bean.getProperty(_innerTopHeightKey),
           (String)_innerTopHeightKey.getDefault());
}
 
Example 51
Project: myfaces-trinidad   File: SimpleInputDateRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected String getContentStyleClass(
  UIComponent component,
  FacesBean   bean)
{
  return "af|inputDate::content";
}
 
Example 52
Project: myfaces-trinidad   File: BodyRenderer.java   Source Code and License 5 votes vote down vote up
private void _storeInitialFocus(
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean)
{

  // The initialFocus functionality is only supported in inaccessible mode,
  // and only platforms that support scripting.
  if (!isInaccessibleMode(rc) || !supportsScripting(rc))
  {
    return;
  }

  // initial focus is the id of the component to which you want the
  // focus to be when the page full-page loads. In a PPR, the focus is
  // not set, which is a good thing.
  String initialFocusID = getInitialFocusId(component, bean);
  if (initialFocusID != null)
  {
    // Put the initial focus id on the rendering context for use in
    // postrender and also so that it can be modified
    // by the component with this id if necessary. For example,
    // the NavigationBar needs its initial focus on the Next button, but
    // the component's id does not get rendered on the Next button. The
    // NavigationBar creates a special id for the Next button, and sticks
    // this id back on the AdfRenderingContext for the body to know about in
    // postrender.
    rc.getProperties().put(XhtmlConstants.INITIAL_FOCUS_CONTEXT_PROPERTY,
                            initialFocusID);
  }
}
 
Example 53
Project: myfaces-trinidad   File: FrameRenderer.java   Source Code and License 5 votes vote down vote up
protected Object getMarginWidth(
  UIComponent component,
  FacesBean   bean)
{
  Object value = bean.getProperty(_marginWidthKey);
  if (value == null)
    value = _marginWidthKey.getDefault();
  return value;
}
 
Example 54
Project: myfaces-trinidad   File: PanelBorderLayoutRenderer.java   Source Code and License 5 votes vote down vote up
private boolean _renderMiddleFacet(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  String           middleFacetName,
  Integer          rowSpan,
  boolean          startTableRow,
  boolean          renderRightFacets
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  UIComponent middleFacet = getFacet(component, middleFacetName);
  if (middleFacet != null)
  {
    if (startTableRow)
      writer.startElement("tr", null);

    _renderInnerFacet(context, middleFacet);

    if (renderRightFacets)
      _renderRightFacets(context, rc, component, rowSpan);

    writer.endElement("tr");
    return true;
  }
  return false;
}
 
Example 55
Project: myfaces-trinidad   File: InputTextRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected String getDefaultLabelValign(
  UIComponent component,
  FacesBean   bean)
{
  if (_simpleInputText.isTextArea(component, bean))
    return "top";

  return null;
}
 
Example 56
Project: javaee8-applications   File: JobController.java   Source Code and License 5 votes vote down vote up
@Override
public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
    if (object == null) {
        return null;
    }
    if (object instanceof Job) {
        Job o = (Job) object;
        return getStringKey(o.getId());
    } else {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "object {0} is of type {1}; expected type: {2}", new Object[]{object, object.getClass().getName(), Job.class.getName()});
        return null;
    }
}
 
Example 57
Project: myfaces-trinidad   File: CellFormatRenderer.java   Source Code and License 5 votes vote down vote up
protected int getRowSpan(
  UIComponent component,
  FacesBean   bean)
{
  Object o = bean.getProperty(_rowSpanKey);
  if (o == null)
    return 1;

  return toInt(o);
}
 
Example 58
Project: myfaces-trinidad   File: ShowDetailRenderer.java   Source Code and License 5 votes vote down vote up
/**
 * Always render an ID, needed for proper PPR.
 */
@Override
protected boolean shouldRenderId(
  FacesContext context,
  UIComponent  component)
{
  return true;
}
 
Example 59
Project: myfaces-trinidad   File: OutputLabelRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected String getDefaultStyleClass(
  UIComponent component,
  FacesBean   bean)
{
  return "af|outputLabel";
}
 
Example 60
Project: TreasureHunting   File: QaController.java   Source Code and License 5 votes vote down vote up
@Override
public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
    if (value == null || value.length() == 0) {
        return null;
    }
    QaController controller = (QaController) facesContext.getApplication().getELResolver().
            getValue(facesContext.getELContext(), null, "qaController");
    return controller.getQa(getKey(value));
}