當前位置: 首頁>>代碼示例>>Java>>正文


Java FacesContext.getCurrentInstance方法代碼示例

本文整理匯總了Java中javax.faces.context.FacesContext.getCurrentInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java FacesContext.getCurrentInstance方法的具體用法?Java FacesContext.getCurrentInstance怎麽用?Java FacesContext.getCurrentInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.faces.context.FacesContext的用法示例。


在下文中一共展示了FacesContext.getCurrentInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: regContaBanco

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
public void regContaBanco(){
    FacesContext facesContext = FacesContext.getCurrentInstance();
    contaBanco.setIdtipoConta(Int(facesContext.getExternalContext().getRequestParameterMap().get("tipoconta")));
    contaBanco.setIdtipoContaContabilistica(Int(facesContext.getExternalContext().getRequestParameterMap().get("contacontabalistica")));
    contaBanco.setIdbanco(Int(facesContext.getExternalContext().getRequestParameterMap().get("banco")));
    contaBanco.setIdTipoMoeda(Int(facesContext.getExternalContext().getRequestParameterMap().get("tipomoeda")));
    contaBanco.setNumConta(facesContext.getExternalContext().getRequestParameterMap().get("numconta"));
    String stra[] = new ContaBancoDao().regAccount(contaBanco);
    if(stra != null && "true".equals(stra[0])){
        RequestContext.getCurrentInstance().execute("limparCBForm()");
        listContaBanco = new ContaBancoDao().getListContaBanco(null);
        Validacao.atualizar("accountTableForm", "tableCantaBanco");
        Message.addInfoMsg("Nova Conta Banco registada com sucesso!","changePassword", "growlChangePassword");
    }else if(stra != null && "false".equals(stra[0]))
    { Message.addErrorMsg(stra[1],"changePassword", "growlChangePassword"); }
    RequestContext.getCurrentInstance().execute("$('.modalProcess').hide()");
}
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:18,代碼來源:ContaBancoBean.java

示例2: createResponse

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
private void createResponse(byte[] buf) throws IOException {
    FacesContext fc = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse) fc
            .getExternalContext().getResponse();

    String filename = generateFileName();

    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-disposition", "attachement; filename=\""
            + filename + "\"");
    response.setContentLength(buf.length);
    OutputStream out;
    out = response.getOutputStream();
    out.write(buf);
    out.flush();
    out.close();
    fc.responseComplete();
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:19,代碼來源:ManageLanguageCtrl.java

示例3: testBasic

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void testBasic()
{
  TestNamingContainer a = new TestNamingContainer(); a.setId("a");
  TestNamingContainer b = new TestNamingContainer(); b.setId("b");
  TestNamingContainer d = new TestNamingContainer(); d.setId("d");
  TestPanel e = new TestPanel(); e.setId("e");
  TestPanel g = new TestPanel(); g.setId("g");
                                 
  FacesContext context = FacesContext.getCurrentInstance();
  context.getViewRoot().getChildren().add(a);

  a.getChildren().add(b);
  b.getChildren().add(d);
  b.getChildren().add(g);
  d.getChildren().add(e);
  
  
  assertEquals("a:b:d:e", e.getClientId(context));
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:21,代碼來源:ClientIdCachingTest.java

示例4: redirect

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@Override
public void redirect(final String url) throws IOException
{
  _checkResponse();

  if (_servletResponse instanceof HttpServletResponse)
  {
    _httpServletResponse.sendRedirect(url);

    FacesContext fc = FacesContext.getCurrentInstance();
    if (fc != null)
    {
      fc.responseComplete();
    }
  }
  else
  {
    throw new IllegalArgumentException(_LOG.getMessage(
      "ONLY_HTTPSERVLETRESPONSE_SUPPORTED"));
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:22,代碼來源:ServletExternalContext.java

示例5: getInstance

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
public Object getInstance() throws InstantiationException
{
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (facesContext == null)
    {
        log.error("Object " + getManagedBeanName() + " cannot be created since the faces context is null");
        return null;
    }

    Application application = facesContext.getApplication();
    Object resolvedObject = null;

    if (isVBExpression(getManagedBeanName()))
    {
        ValueBinding vb = application.createValueBinding(getManagedBeanName());
        if (vb != null)
        {
            resolvedObject = vb.getValue(facesContext);
        }
    }
    else
    {
        VariableResolver resolver = application.getVariableResolver();
        resolvedObject = resolver.resolveVariable(facesContext, getManagedBeanName());
    }

    return resolvedObject;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:29,代碼來源:JsfCreator.java

示例6: getViewMap

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public Map<String, Object> getViewMap(boolean create)
{
  // Note: replace this method body with a call to UIViewRoot.getViewMap(boolean) when
  // Trinidad is upgraded to use JSF 2.0

  FacesContext facesContext = FacesContext.getCurrentInstance();
  UIViewRoot viewRoot = facesContext.getViewRoot();
  Map<String, Object> viewMap = null;

  if (viewRoot != null)
  {
    Map<String, Object> attrs = viewRoot.getAttributes();

    viewMap = (Map<String, Object>)attrs.get(_VIEW_MAP_KEY);
    if (viewMap == null && create)
    {
      // Note, it is not valid to refer to the request context from outside of the request's
      // thread. As such, synchronization and thread safety is not an issue here.
      // This coincides with the JSF 2.0 code not using syncronization and using the non-thread
      // safe HashMap.
      viewMap = new HashMap<String, Object>();
      attrs.put(_VIEW_MAP_KEY, viewMap);
    }
  }

  return viewMap;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:30,代碼來源:MRequestContext.java

示例7: handleFileUpload

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
public void handleFileUpload(String imagem) 
    {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        
        try
        {       
         
//            System.err.println(typeImagem(imagem));
            byte[] bd = org.apache.poi.util.IOUtils.toByteArray(typeImagem(imagem).getInputStream());
           
            ServletContext scontext = (ServletContext) facesContext.getExternalContext().getContext();
            String arquivo = scontext.getRealPath("/Imagem/");
//            System.err.println(arquivo);
            File f = new File(arquivo);
            for(File dd: f.listFiles())
                if(dd.getName().contains(SessionUtil.getUserlogado().getNomeAcesso()+imagem))
                    dd.delete();
            
            try (FileOutputStream fos = new FileOutputStream(arquivo+"/"+SessionUtil.getUserlogado().getNif()+imagem+ii+".jpg")) 
            {fos.write(bd);}
            
            alterarImagem(imagem,"/Imagem/"+SessionUtil.getUserlogado().getNif()+imagem+ii+".jpg");
            
            ii++;
            RequestContext.getCurrentInstance().update("empresaReg:"+imagem);
        }
        catch (IOException ex) 
        {
            Logger.getLogger(UtilizadorBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:32,代碼來源:EmpresaBean.java

示例8: _removeChild

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private static void _removeChild(UIComponent uic, String removableChildId)
{
  UIComponent removableChild = _findChildById(uic, removableChildId);
  if (removableChild != null)
  {
    List<UIComponent> children = uic.getChildren();
    children.remove(removableChild);
    ComponentChange rca = new RemoveChildComponentChange(removableChildId);
    FacesContext fc = FacesContext.getCurrentInstance();
    ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
    apm.addComponentChange(fc, uic, rca);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:15,代碼來源:ChangeBean.java

示例9: DialogRequest

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public DialogRequest(
  UIViewRoot         targetRoot,
  String             clientId,
  String             formId,
  Map<String,Object> dialogProperties,
  boolean            usePopup
  )
{
  _clientId = clientId;
  _formId   = formId;
  _usePopup = usePopup;

  if (dialogProperties == null)
    dialogProperties = Collections.emptyMap();

  Object width = dialogProperties.get("width");
  Object height = dialogProperties.get("height");

  FacesContext context = FacesContext.getCurrentInstance();

  String url;
  
  if (usePopup)
  {
    url = context.getApplication().getViewHandler().getActionURL(context, targetRoot.getViewId());
  }
  else
  {
    url = FredJSP.getRedirectURL(context,
                                targetRoot,
                                CoreRenderer.toString(width),
                                CoreRenderer.toString(height));
  }
  
  PageFlowScopeProvider provider = RequestContext.getCurrentInstance().getPageFlowScopeProvider();
  _url = context.getExternalContext().encodeActionURL(provider.encodeDialogPageFlowScopeURL(context, url));
  
  _dialogProperties  = dialogProperties;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:41,代碼來源:DialogRequest.java

示例10: login

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
/**
 * Process login. Connect to server and move to folder display page.
 */
public String login()
{
  try
  {
    // login to the IMAP server
    Properties props = new Properties();
    Session session = Session.getInstance(props, null);
    Store store = session.getStore("imap");
    store.connect(_server, _username, _password);
    setStore(store);

    setRootFolders(FolderData.toFolderData(this, store.getDefaultFolder().list()));

    // TODO: Add logged in indicator to restrict access

    _gotoFolder(null);

    // Set up the user's preferences;  in a real app, these would
    // be persisted somewhere.
    PreferencesData preferences = new PreferencesData();
    setPreferences(preferences);
  }
  // catch all exceptions and report them as errors
  catch (Exception e)
  {
    FacesMessage errorMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                                 e.getMessage(), null);

    FacesContext context = FacesContext.getCurrentInstance();
  context.addMessage(null, errorMessage);

    return null;
  }

  return "success";
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:40,代碼來源:AccountData.java

示例11: resolveImagePathForName

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@Override
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
    if (FacesContext.getCurrentInstance() != null)
    {
        return FileTypeImageUtils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
    }
    else
    {
        return null;
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:13,代碼來源:FacesImageResolver.java

示例12: getTokenToViewIdString

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
/**
 * Generate a string showing the token and the view id we have saved for that token
 * 
 * This method should only be called when debugTokenCache() is true
 */
public static String getTokenToViewIdString(String token)
{      
  if (!_DEBUG_TOKEN_CACHE)
    throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
  FacesContext context = FacesContext.getCurrentInstance();
  return _getTokenToViewIdString( _getTokenToViewIdMap(context), token);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:13,代碼來源:TokenCacheDebugUtils.java

示例13: pesquisaCB

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
public void pesquisaCB(){
    FacesContext facesContext = FacesContext.getCurrentInstance();
    pesquisaConta = facesContext.getExternalContext().getRequestParameterMap().get("pesq");
    listContaBanco = new ContaBancoDao().resultPesqu(pesquisaConta, false, null);
    Validacao.atualizar("accountTableForm", "tableCantaBanco");
    RequestContext.getCurrentInstance().execute("$('.modalProcess').hide()");
}
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:8,代碼來源:ContaBancoBean.java

示例14: verifyViewLocale

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
/**
 * Verifies that the view locale is equal to the user's locale
 * 
 */
public static void verifyViewLocale() {
    FacesContext fc = FacesContext.getCurrentInstance();

    HttpServletRequest request = (HttpServletRequest) fc
            .getExternalContext().getRequest();
    HttpSession session = request.getSession();
    String localeString = null;
    if (session != null) {
        localeString = (String) session.getAttribute("loggedInUserLocale");
    }

    // if the view locale differs from the users locale change the view
    // locale
    Locale locale = fc.getViewRoot().getLocale();
    if (localeString != null && !locale.toString().equals(localeString)) {
        Iterator<Locale> it = fc.getApplication().getSupportedLocales();
        while (it.hasNext()) {
            locale = it.next();
            if (locale.toString().equals(localeString)) {
                fc.getViewRoot().setLocale(locale);
                return;
            }
        }
        // we use the default locale if the requested locale was not
        // found
        if (!fc.getViewRoot().getLocale()
                .equals(fc.getApplication().getDefaultLocale())) {
            fc.getViewRoot().setLocale(
                    fc.getApplication().getDefaultLocale());
        }
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:37,代碼來源:JSFUtils.java

示例15: init

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@PostConstruct
public void init() {
    context = FacesContext.getCurrentInstance();

    /**
     * FG Info Flash: We need flash to make the param survive one redirect request
     * otherwise param will be null
     **/
    flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
    //Get UserId of user, who owns session
    Map<String, Object> session = context.getExternalContext().getSessionMap();


    id = context.getExternalContext().getRequestParameterMap().get("userid");

    flash.put("uid", id);


    String userProfId = String.valueOf(context.getExternalContext().getFlash().get("uid"));


    LOG.info("userProfId: " + userProfId);

    if (session.size() != 0 && session.get("user") != null) {

        userId = (int) session.get("user");
        LOG.info("SESSIOn UID: " + userId);
    } else {
        try {
            context.getExternalContext().redirect("/pse/login.xhtml");
        } catch (IOException e) {
            LOG.error("Can't redirect to /pse/login.xhtml");

        }
    }
    requestedCommunityList = new ArrayList<>();
    approvedCommunityList = new ArrayList<>();

    requestedCommunityList = service.getPending();
    LOG.info("Size of Requested Comm: " + requestedCommunityList.size());

    approvedCommunityList = service.getApproved();
    LOG.info("Size of Requested Comm: " + approvedCommunityList.size());
}
 
開發者ID:chr-krenn,項目名稱:chr-krenn-fhj-ws2017-sd17-pse,代碼行數:45,代碼來源:AdminDataBean.java


注:本文中的javax.faces.context.FacesContext.getCurrentInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。