本文整理匯總了Java中javax.faces.context.FacesContext類的典型用法代碼示例。如果您正苦於以下問題:Java FacesContext類的具體用法?Java FacesContext怎麽用?Java FacesContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FacesContext類屬於javax.faces.context包,在下文中一共展示了FacesContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDefaultColumns
import javax.faces.context.FacesContext; //導入依賴的package包/類
@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;
}
示例2: onPoll
import javax.faces.context.FacesContext; //導入依賴的package包/類
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;
}
}
}
示例3: encodeBegin
import javax.faces.context.FacesContext; //導入依賴的package包/類
@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);
}
}
示例4: _removeSimpleComponentChange
import javax.faces.context.FacesContext; //導入依賴的package包/類
/**
* 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);
}
示例5: validate
import javax.faces.context.FacesContext; //導入依賴的package包/類
@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);
}
}
示例6: appendChildToDocument
import javax.faces.context.FacesContext; //導入依賴的package包/類
/**
* 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);
}
}
示例7: _getMaximumMessage
import javax.faces.context.FacesContext; //導入依賴的package包/類
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);
}
示例8: skipDecode
import javax.faces.context.FacesContext; //導入依賴的package包/類
@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);
}
示例9: call
import javax.faces.context.FacesContext; //導入依賴的package包/類
@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);
}
}
示例10: saveState
import javax.faces.context.FacesContext; //導入依賴的package包/類
@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);
}
示例11: getAsString
import javax.faces.context.FacesContext; //導入依賴的package包/類
@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";
}
}
示例12: getContainerClientId
import javax.faces.context.FacesContext; //導入依賴的package包/類
/**
* 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;
}
示例13: treeToTable
import javax.faces.context.FacesContext; //導入依賴的package包/類
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;
/* */ }
/* */ }
/* */ }
示例14: renderShortDescAsHiddenLabel
import javax.faces.context.FacesContext; //導入依賴的package包/類
/**
*/
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);
}
}
}
}
示例15: toActionUri
import javax.faces.context.FacesContext; //導入依賴的package包/類
/**
* 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);
}
}