Java Code Examples for javax.faces.context.FacesContext

The following are top voted examples for showing how to use javax.faces.context.FacesContext. 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: SimpleInputColorRenderer.java   View source code 7 votes vote down vote up
@Override
protected Integer getDefaultColumns(
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean)
{
  Integer columnsInteger = null;

  Converter converter = getConverter(component, bean);

  // Ignoring the "default" converter code is intentional;  we'll just
  // fall through to _DEFAULT_COLUMNS here to save time
  if (converter instanceof ColorConverter)
  {
    int columns = ((ColorConverter) converter).getColumns(FacesContext.getCurrentInstance());
    columnsInteger = columns;
  }
  else
  {
    columnsInteger = _DEFAULT_COLUMNS;
  }

  return columnsInteger;
}
 
Example 2
Project: myfaces-trinidad   File: UIXComponentBase.java   View source code 6 votes vote down vote up
@Override
public void encodeBegin(FacesContext context) throws IOException
{
  if (context == null)
    throw new NullPointerException();

  // Call UIComponent.pushComponentToEL(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
  pushComponentToEL(context, this);

  if (!isRendered())
    return;

  context.getApplication().publishEvent(context,  PreRenderComponentEvent.class, UIComponent.class, this);

  _cacheRenderer(context);
  Renderer renderer = getRenderer(context);

  // if there is a Renderer for this component
  if (renderer != null)
  {
    renderer.encodeBegin(context, this);
  }
}
 
Example 3
Project: myfaces-trinidad   File: SessionChangeManager.java   View source code 6 votes vote down vote up
/**
 * Removes (if any) the previously added simple component change for the supplied component and 
 *  attribute 
 *  
 * @return The removed ComponentChange instance, or null if the ComponentChange was not removed
 */
private ComponentChange _removeSimpleComponentChange(
  FacesContext facesContext,
  UIComponent component,
  AttributeComponentChange componentChange)
{
  String sessionKey = _getSessionKey(facesContext);
  ChangesForView changesForView = _getChangesForView(facesContext, sessionKey, true);
  String logicalScopedId = 
    ComponentUtils.getLogicalScopedIdForComponent(component, facesContext.getViewRoot());

  // first remove from the simple component changes structure that we maintained for convenience
  changesForView.removeAttributeChange(logicalScopedId, componentChange);

  // next, remove (replace with null) any attribute change for this attribute from the global 
  //  changes list, handling the case where the component could have been moved after the 
  //  attribute change was added
  return _replaceAttributeChange(facesContext,
                                 component,
                                 componentChange.getAttributeName(),
                                 null,
                                 true);
}
 
Example 4
Project: oscm   File: TenantValidator.java   View source code 6 votes vote down vote up
@Override
public void validate(FacesContext context, UIComponent uiComponent,
        Object input) throws ValidatorException {
    
    TenantService tenantService = serviceLocator.findService(TenantService.class);
    
    String tenantKey = input.toString();

    if (StringUtils.isBlank(tenantKey) || "0".equals(tenantKey)) {
        return;
    }

    try {
        tenantService.getTenantByKey(Long.parseLong(tenantKey));
    } catch (ObjectNotFoundException e) {

        String msg = JSFUtils
                .getText(BaseBean.ERROR_TENANT_NO_LONGER_EXISTS, null);
        FacesMessage facesMessage = new FacesMessage(
                FacesMessage.SEVERITY_ERROR, msg, null);
        throw new ValidatorException(facesMessage);
    }
}
 
Example 5
Project: myfaces-trinidad   File: ChangeBean.java   View source code 6 votes vote down vote up
/**
 * Appends an image child to the panelGroup in the underlying JSP document
 */
public void appendChildToDocument(ActionEvent event)
{
  UIComponent eventSource = event.getComponent();
  UIComponent uic = eventSource.findComponent("pg1");
  
  // only allow the image to be added once
  if (_findChildById(uic,"oi3") != null)
    return;
    
  FacesContext fc = FacesContext.getCurrentInstance();

  DocumentFragment imageFragment = _createDocumentFragment(_IMAGE_MARK_UP);
  
  if (imageFragment != null)
  {
    DocumentChange change = new AddChildDocumentChange(imageFragment);
    
    ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
    
    apm.addDocumentChange(fc, uic, change);
  }
}
 
Example 6
Project: myfaces-trinidad   File: DateTimeRangeValidator.java   View source code 6 votes vote down vote up
private FacesMessage _getMaximumMessage(
  FacesContext context,
  UIComponent component,
  Object value,
  Object max)
{
  Converter converter = _getConverter(context, component);

  Object cValue = _getConvertedValue(context, component, converter, value);
  Object cMax   = _getConvertedValue(context, component, converter, max);

  Object msg   = _getRawMaximumMessageDetail();
  Object label = ValidatorUtils.getComponentLabel(component);

  Object[] params = {label, cValue, cMax};

  return MessageFactory.getMessage(context,
                                   MAXIMUM_MESSAGE_ID,
                                   msg,
                                   params,
                                   component);
}
 
Example 7
Project: myfaces-trinidad   File: XhtmlRenderer.java   View source code 6 votes vote down vote up
@Override
protected boolean skipDecode(FacesContext context)
{
  // =-=AEW HACK!  When executing a "dialog return" from the filter,
  // we've generally saved off the original parameters such that
  // decoding again isn't a problem.  But we can run into some problems:
  //  (1) A component that doesn't know about ReturnEvents:  it'll
  //    decode again, thereby firing the event again that launched
  //    the dialog (and you go right back to the dialog)
  //  (2) The component does know about ReturnEvents, but
  //      someone launches a dialog in response to the ReturnEvent,
  //      after setting the value of an input field.  But since
  //      we've still saved off the original parameters,
  //      now we're back in
  // The best fix would really be somehow skipping the Apply Request
  // Values phase altogether, while still queueing the ReturnEvent
  // properly.  But how the heck is that gonna happen?
  return TrinidadFilterImpl.isExecutingDialogReturn(context);
}
 
Example 8
Project: APacheSynapseSimplePOC   File: MyfacesTest.java   View source code 6 votes vote down vote up
@Override
public Object call () throws Exception {
    java.lang.reflect.Method setFC = FacesContext.class.getDeclaredMethod("setCurrentInstance", FacesContext.class);
    setFC.setAccessible(true);
    ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    FacesContext ctx = createMockFacesContext();
    try {
        setFC.invoke(null, ctx);
        return super.call();
    }
    finally {
        setFC.invoke(null, (FacesContext) null);
        Thread.currentThread().setContextClassLoader(oldTCCL);
    }
}
 
Example 9
Project: myfaces-trinidad   File: UIXTreeTemplate.java   View source code 6 votes vote down vote up
@Override
public Object saveState(FacesContext context)
{
  RowKeySet rowKeys = (RowKeySet)super.getProperty(DISCLOSED_ROW_KEYS_KEY);
  if (rowKeys != null)
  {
    // make sure the set does not pin the model in memory
    rowKeys.setCollectionModel(null);
  }
  rowKeys = (RowKeySet)super.getProperty(SELECTED_ROW_KEYS_KEY);
  if (rowKeys != null)
  {
    // make sure the set does not pin the model in memory
    rowKeys.setCollectionModel(null);
  }
  return super.saveState(context);
}
 
Example 10
Project: tap17-muggl-javaee   File: GuardianConverter.java   View source code 6 votes vote down vote up
@Override
public String getAsString(FacesContext context, UIComponent component, Object object) {
    if (object == null) {
        return "";
    }
    
    Guardian guardian = (Guardian) object;
    Long id = guardian.getId();
    if (id != null) {
        String stringId = String.valueOf(id.longValue());
        this.getViewMap(context).put(stringId, object);
        return stringId;
    } else {
        return "0";
    }
}
 
Example 11
Project: myfaces-trinidad   File: UIXDecorateCollectionTemplate.java   View source code 6 votes vote down vote up
/**
 * Gets the client-id of this component, without any NamingContainers.
 * This id changes depending on the currency Object.
 * Because this implementation uses currency strings, the local client ID is
 * not stable for very long. Its lifetime is the same as that of a
 * currency string.
 * @see #getCurrencyString
 * @return the local clientId
 */
@Override
public final String getContainerClientId(FacesContext context)
{
  String id = getClientId(context);
  String key = getCurrencyString();
  if (key != null)
  {
    StringBuilder bld = __getSharedStringBuilder();
    bld.append(id).append(NamingContainer.SEPARATOR_CHAR).append(key);
    id = bld.toString();
  }

  return id;
}
 
Example 12
Project: Multicentro_Mascotas   File: ColumnManagerView.java   View source code 6 votes vote down vote up
public void treeToTable()
/*     */   {
/*  77 */     Map params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
/*  78 */     String property = (String)params.get("property");
/*  79 */     String droppedColumnId = (String)params.get("droppedColumnId");
/*  80 */     String dropPos = (String)params.get("dropPos");
/*     */ 
/*  82 */     String[] droppedColumnTokens = droppedColumnId.split(":");
/*  83 */     int draggedColumnIndex = Integer.parseInt(droppedColumnTokens[(droppedColumnTokens.length - 1)]);
/*  84 */     int dropColumnIndex = draggedColumnIndex + Integer.parseInt(dropPos);
/*     */ 
/*  87 */     this.columns.add(dropColumnIndex, new ColumnModel(property.toUpperCase(), property));
/*     */ 
/*  90 */     TreeNode root = (TreeNode)this.availableColumns.getChildren().get(0);
/*  91 */     for (TreeNode node : root.getChildren()) {
/*  92 */       ColumnModel model = (ColumnModel)node.getData();
/*  93 */       if (model.getProperty().equals(property)) {
/*  94 */         root.getChildren().remove(node);
/*  95 */         break;
/*     */       }
/*     */     }
/*     */   }
 
Example 13
Project: myfaces-trinidad   File: FormElementRenderer.java   View source code 6 votes vote down vote up
/**
 */
protected void renderShortDescAsHiddenLabel(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  if (HiddenLabelUtils.supportsHiddenLabels(rc) &&
      isHiddenLabelRequired(rc))
  {
    String clientId = getClientId(context, component);
    if (HiddenLabelUtils.wantsHiddenLabel(rc, clientId))
    {
      String hiddenLabel = getHiddenLabel(component, bean);
      if (hiddenLabel != null)
      {
        HiddenLabelUtils.outputHiddenLabel(context,
                                           rc,
                                           clientId,
                                           hiddenLabel,
                                           component);
      }
    }
  }
}
 
Example 14
Project: myfaces-trinidad   File: CoreRenderer.java   View source code 6 votes vote down vote up
/**
 * Coerces an object into an action URI, calling the view-handler.
 */
static public String toActionUri(FacesContext fc, Object o)
{
  if (o == null)
    return null;

  String uri = o.toString();

  // Treat two slashes as server-relative
  if (uri.startsWith("//"))
  {
    return uri.substring(1);
  }
  else
  {
    return fc.getApplication().getViewHandler().getActionURL(fc, uri);
  }
}
 
Example 15
Project: myfaces-trinidad   File: DesktopPanelPageHeaderRenderer.java   View source code 6 votes vote down vote up
/**
 * render a table row with the navigation2
 * @return void
 */
private void _renderNavigation2(
  FacesContext   context,
  ResponseWriter writer,
  UIComponent    navigation2,
  int            colSpan
  ) throws IOException
{
    writer.startElement("tr", null);
    writer.startElement("td", null);

    if (colSpan > 1)
      writer.writeAttribute("colspan", colSpan, null);

    writer.writeAttribute("width",
                          "100%", null);

    encodeChild( context, navigation2 );


    writer.endElement("td");
    writer.endElement("tr");
}
 
Example 16
Project: myfaces-trinidad   File: ProgressStepsBean.java   View source code 6 votes vote down vote up
public void onPoll(PollEvent event)
{
  if ( __model != null && (__model.getMaximum() <= __model.getValue()) )
  {
    //pu: This means the background task is complete.
    //  End the task and navigate off to a different page.
    endProcess();
    try
    {
      ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
      ec.redirect("../components/progressEnd.jspx?taskStatus=completed");
    }
    catch(IOException ioe)
    {
      _LOG.log(Level.WARNING, "Could not redirect", ioe);
    }
    catch (RuntimeException re)
    {
      _LOG.log(Level.SEVERE, "Could not redirect", re);
      throw re;
    }
  }
}
 
Example 17
Project: myfaces-trinidad   File: Scriptlet.java   View source code 6 votes vote down vote up
/**
 * Outputs the scriptlet.
 */
protected void outputScriptletImpl(
  FacesContext        context,
  RenderingContext arc) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();

  writer.startElement("script", null);
  XhtmlRenderer.renderScriptDeferAttribute(context, arc);
  // Bug #3426092:
  // Render the type="text/javascript" attribute in accessibility mode
  XhtmlRenderer.renderScriptTypeAttribute(context, arc);

  outputScriptletContent(context, arc);
  writer.endElement("script");
}
 
Example 18
Project: myfaces-trinidad   File: BodyRenderer.java   View source code 6 votes vote down vote up
private void _renderNoScript(
  FacesContext     context,
  RenderingContext rc
  ) throws IOException
{
  // Some accessibility standards rather oddly claim that NOSCRIPT
  // tags are essential for compliance.  So, render NOSCRIPT, at
  // least when we're not in "inacessible" mode.
  //
  // But don't bother in design time mode - this check is
  // largely there for JDev 10.1.3 preview, which was rendering
  // the contents of any NOSCRIPT tags in the VE, but it's
  // a check that does no harm.
  if (!isInaccessibleMode(rc) && !rc.isDesignTime())
  {
    ResponseWriter writer = context.getResponseWriter();
    writer.startElement("noscript",null);
    String message = rc.getTranslatedString("NO_SCRIPT_MESSAGE");
    writer.writeText(message, null);
    writer.endElement("noscript");
  }
}
 
Example 19
Project: myfaces-trinidad   File: UIXTreeTableTemplate.java   View source code 5 votes vote down vote up
/**
 * Override to update the container client id cache before validations
 */
@Override
public void processValidators(FacesContext context)
{
  _resetContainerClientIdCache();
  super.processValidators(context);
}
 
Example 20
Project: myfaces-trinidad   File: CoreResponseStateManager.java   View source code 5 votes vote down vote up
private StateManager.SerializedView _getSerializedView(FacesContext context, Object state)
{

  StateManager.SerializedView view;
  if (state instanceof StateManager.SerializedView)
  {
    view = (StateManager.SerializedView) state;
  }
  else
  {
    if (state instanceof Object[])
    {
      Object[] stateArray = (Object[]) state;

      // in theory the state should be a black box, but the RI makes assumptions
      // that the state is an array of length 2
      if (stateArray.length == 2)
      {
        StateManager stateManager =
          context.getApplication().getStateManager();
        view =
            stateManager.new SerializedView(stateArray[0], stateArray[1]);
      }
      else
      {
        throw new IllegalArgumentException(_LOG.getMessage("UNEXPECTED_STATE"));
      }
    }
    else
    {
      throw new IllegalArgumentException(_LOG.getMessage("UNEXPECTED_STATE"));
    }
  }

  return view;
}
 
Example 21
Project: myfaces-trinidad   File: MethodBindingMethodExpression.java   View source code 5 votes vote down vote up
public Object invoke(ELContext elContext, Object[] params)
{
  try
  {
    return _binding.invoke(FacesContext.getCurrentInstance(), params);
  }
  // Convert EvaluationExceptions into ELExceptions
  catch (EvaluationException ee)
  {
    throw new ELException(ee.getMessage(), ee.getCause());
  }
}
 
Example 22
Project: myfaces-trinidad   File: ValueExpressionValueBinding.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
public Class getType(FacesContext facesContext)
{
  try
  {
    return _ve.getType(facesContext.getELContext());
  }
  // Convert EL exceptions into EvaluationExceptions
  catch (ELException ee)
  {
    throw new EvaluationException(ee.getMessage(), ee.getCause());
  }
}
 
Example 23
Project: myfaces-trinidad   File: LabelAndMessageRenderer.java   View source code 5 votes vote down vote up
@Override
protected boolean shouldRenderId(
  FacesContext context,
  UIComponent  component)
{
  return false;
}
 
Example 24
Project: myfaces-trinidad   File: LongRangeValidator.java   View source code 5 votes vote down vote up
private static String _getTrRangeValidator(
    FacesContext context,
    UIComponent component,
    String max,
    String min,
    Map<String, String> messages)
{
  StringBuilder outBuffer = new StringBuilder();
  outBuffer.append("new TrRangeValidator(");
  outBuffer.append(max);
  outBuffer.append(',');
  outBuffer.append(min);
  outBuffer.append(',');
  if(messages == null)
  {
    outBuffer.append("null");
  }
  else
  {
    try
    {
      JsonUtils.writeMap(outBuffer, messages, false);
    }
    catch (IOException e)
    {
      outBuffer.append("null");
    }
  }
  outBuffer.append(")");

  return outBuffer.toString();
}
 
Example 25
Project: myfaces-trinidad   File: PollRenderer.java   View source code 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void decode(
  FacesContext facesContext,
  UIComponent  component,
  @SuppressWarnings("unused")
  FacesBean    facesBean,
  String       clientId)
{
  Map<String, String> parameters =
    facesContext.getExternalContext().getRequestParameterMap();

  Object event = parameters.get(XhtmlConstants.EVENT_PARAM);
  if (XhtmlConstants.POLL_EVENT.equals(event))
  {
    Object source = parameters.get(XhtmlConstants.SOURCE_PARAM);
    String id = clientId == null ? component.getClientId(facesContext) : clientId;

    if (id.equals(source))
    {
      // This component always uses PPR (unless not supported at all)
      PartialPageUtils.forcePartialRendering(facesContext);

      // And forcibly re-render ourselves - because that's how
      // we get the poll re-started
      RequestContext.getCurrentInstance().addPartialTarget(component);

      UIXPoll poll = (UIXPoll) component;
      (new PollEvent(component)).queue();
      if (poll.isImmediate())
        facesContext.renderResponse();
    }
  }
}
 
Example 26
Project: myfaces-trinidad   File: StyleContextImpl.java   View source code 5 votes vote down vote up
public boolean checkStylesModified()
{
  FacesContext context = FacesContext.getCurrentInstance();
  String checkTimestamp =
    context.getExternalContext().getInitParameter(Configuration.CHECK_TIMESTAMP_PARAM);

  // in production stage we don't want TRUE here;
  // a WARNING will be triggered by the ViewHandlerImpl.java
  return "true".equals(checkTimestamp);
}
 
Example 27
Project: chr-krenn-fhj-ws2017-sd17-pse   File: LoginBean.java   View source code 5 votes vote down vote up
public String logout() {
    FacesContext.getCurrentInstance().getExternalContext().invalidateSession();

    //TODO return isn`t needed in case each class has the handling if no session exists
    return "/login.xhtml?faces-redirect=true";

    //TODO smarter would be the next line without return a string - at the moment the instance of LoginBean is new create so the errorMsg isn`t shown
}
 
Example 28
Project: myfaces-trinidad   File: ValueExpressionValueBinding.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
public Object getValue(FacesContext facesContext)
{
  try
  {
    return _ve.getValue(facesContext.getELContext());
  }
  // Convert EL exceptions into EvaluationExceptions
  catch (ELException ee)
  {
    throw new EvaluationException(ee.getMessage(), ee.getCause());
  }    
}
 
Example 29
Project: DocIT   File: EmployeeBean.java   View source code 5 votes vote down vote up
/** Creates a new instance of EmployeeBean */
public EmployeeBean() {
    HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

    String id = request.getParameter("employeeId");
    currentEmployee = Long.valueOf(id);
    
    loadEmployee(currentEmployee);
}
 
Example 30
Project: ctsms   File: SketchPadRenderer.java   View source code 5 votes vote down vote up
private void encodeColorPicker(FacesContext context, SketchPad sketchPad) throws IOException {
	ResponseWriter writer = context.getResponseWriter();
	String colorPickerId = getInputId(sketchPad, context) + "_colorPicker";
	writer.startElement("td", null);
	writer.startElement("input", null);
	writer.writeAttribute("type", "text", null);
	writer.writeAttribute("id", colorPickerId, null);
	writer.writeAttribute("name", colorPickerId, null);
	writer.endElement("input");
	writer.endElement("td");
}
 
Example 31
Project: myfaces-trinidad   File: NavigationBarRenderer.java   View source code 5 votes vote down vote up
protected String getIconURI(
  UIXRenderingContext context,
  boolean          isBack,
  boolean          isEnabled
)
{
  // get the image location
  String iconName;

  if (isBack)
  {
    if (isEnabled)
    {
      iconName   = AF_TABLE_NB_PREV_ICON_NAME;
    }
    else
    {
      iconName   = AF_TABLE_NB_PREV_DISABLED_ICON_NAME;
    }
  }
  else
  {
    if (isEnabled)
    {
      iconName   = AF_TABLE_NB_NEXT_ICON_NAME;
    }
    else
    {
      iconName   = AF_TABLE_NB_NEXT_DISABLED_ICON_NAME;
    }
  }
  Skin skin = context.getSkin();
  RenderingContext arc = RenderingContext.getCurrentInstance();
  FacesContext fContext = context.getFacesContext();

  String iconURI = (String)(skin.getIcon(
                                        iconName).getImageURI(fContext, arc));

  return iconURI;
}
 
Example 32
Project: myfaces-trinidad   File: PageFlowScopeMap.java   View source code 5 votes vote down vote up
static private TokenCache _getRootTokenCache(FacesContext context,
                                             int lifetime)
{
  return TokenCache.getTokenCacheFromSession(context.getExternalContext(),
                                             _PAGE_FLOW_SCOPE_CACHE,
                                             true,
                                             lifetime);
}
 
Example 33
Project: myfaces-trinidad   File: PartialPageUtils.java   View source code 5 votes vote down vote up
/**
 * Mark that PPR is in fact active during rendering.
 */
@SuppressWarnings("unchecked")
public static void markPPRActive(FacesContext context)
{
  Map<String, Object> requestScope =
    context.getExternalContext().getRequestMap();
  
  requestScope.put(_PPR_ACTIVE_FLAG_NAME, Boolean.TRUE);
}
 
Example 34
Project: myfaces-trinidad   File: DoubleRangeValidator.java   View source code 5 votes vote down vote up
private static String _getTrRangeValidator(
    FacesContext context,
    UIComponent component,
    String max,
    String min,
    Map<String, String> messages)
{
  StringBuilder outBuffer = new StringBuilder();
  outBuffer.append("new TrRangeValidator(");
  outBuffer.append(max);
  outBuffer.append(',');
  outBuffer.append(min);
  outBuffer.append(',');
  if(messages == null)
  {
    outBuffer.append("null");
  }
  else
  {
    try
    {
      JsonUtils.writeMap(outBuffer, messages, false);
    }
    catch (IOException e)
    {
      outBuffer.append("null");
    }
  }
  outBuffer.append(')');

  return outBuffer.toString();
}
 
Example 35
Project: myfaces-trinidad   File: SimpleSelectBooleanRadioRenderer.java   View source code 5 votes vote down vote up
/**
 * Returns true if the component should render the ID as a name.
 * By default, don't if the component is readonly.
 */
@Override
protected boolean shouldRenderName(
  FacesContext context,
  UIComponent  component)
{
  return false;
}
 
Example 36
Project: myfaces-trinidad   File: FacesRenderingContext.java   View source code 5 votes vote down vote up
/**
 * Gets the current RenderingContext.
 * @todo Rename to getCurrentInstance()
 * @todo Why are passing a UIComponent?  In some places,
 *   we're passing null for the component!
 */
static public UIXRenderingContext getRenderingContext(
  FacesContext fContext,
  UIComponent  component) throws IOException
{
  return getRenderingContext(fContext, component, true);
}
 
Example 37
Project: myfaces-trinidad   File: UIXComponentBase.java   View source code 5 votes vote down vote up
@Override
public void restoreState(FacesContext context, Object state)
{
  if (state == null)
  {
    return;
  }

  Object[] stateArr = (Object[]) state;
  Object saved = stateArr[0];

  _delegate = (ComponentSystemEventListener) ((saved == null) ? UIComponent .getCurrentComponent(context)
                                            : StateUtils.restoreStateHolder(context, saved));
  _componentClass = (Class<?>)stateArr[1];
}
 
Example 38
Project: myfaces-trinidad   File: ColumnGroupRenderer.java   View source code 5 votes vote down vote up
/**
 * @todo Will need to support TREE_NODE_STAGE
 */
@Override
protected void encodeAll(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  TableRenderingContext tContext =
    TableRenderingContext.getCurrentInstance();

  RenderStage rs = tContext.getRenderStage();
  int stage = rs.getStage();
  switch (stage)
  {
  case RenderStage.INITIAL_STAGE:
    _computeMode(context, tContext, component);
    break;
  case RenderStage.COLUMN_HEADER_STAGE:
    _renderHeaderMode(context, rc, tContext, component);
    break;
  // For these stages, simply render the children; we
  // need no special processing at the column group level
  case RenderStage.DATA_STAGE:
  case RenderStage.START_ROW_STAGE:
  case RenderStage.COLUMN_FOOTER_STAGE:
    _renderChildren(context, component, null /*parentNode*/);
    break;
  case RenderStage.END_STAGE:
    // Do nothing.  =-=AEW This is only legit because we happen
    // to know that ColumnRenderer does nothing here too.
    break;
  default:
    throw new AssertionError("Bad renderStage:"+stage);
  }
}
 
Example 39
Project: myfaces-trinidad   File: AliasedScriptlet.java   View source code 5 votes vote down vote up
@Override
protected void outputScriptletImpl(
  FacesContext        context,
  RenderingContext arc) throws IOException
{
  if (_dependencies != null)
  {
    for (int i = 0; i < _dependencies.length; i++)
      outputDependency(context, arc, _dependencies[i]);
  }

  outputDependency(context, arc, _actualLibrary);
}
 
Example 40
Project: myfaces-trinidad   File: DesktopTableRenderer.java   View source code 5 votes vote down vote up
private void _renderEmptyTable(FacesContext context, RenderingContext rc, TableRenderingContext tContext)
  throws IOException
{
  int specialCols = tContext.hasSelection()? 1: 0;
  if (tContext.getDetail() != null)
    specialCols++;
  renderEmptyTableRow(context, rc, tContext, specialCols);
}