• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Faces类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.omnifaces.util.Faces的典型用法代码示例。如果您正苦于以下问题:Java Faces类的具体用法?Java Faces怎么用?Java Faces使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Faces类属于org.omnifaces.util包,在下文中一共展示了Faces类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: recordEvent

import org.omnifaces.util.Faces; //导入依赖的package包/类
@Override
public void recordEvent(WebUser webUser, WebUser adminUser, WebEvent event, String comment) {

	AuditLog auditLog = new AuditLog();

	auditLog.setWebUserId(webUser.getId());
	auditLog.setUserName(webUser.getUserName());
	if (adminUser != null) {
		auditLog.setAdminUserId(adminUser.getId());
		auditLog.setAdminUserName(adminUser.getUserName());
	}

	auditLog.setWebEvent(event);
	auditLog.setEventDate(new Date());
	auditLog.setComment(comment);

	if (webUser.getRemoteAddress() == null) {
		auditLog.setRemoteAddress(Faces.getRemoteAddr());
	}
	else {
		auditLog.setRemoteAddress(webUser.getRemoteAddress());
	}

	auditLogRepository.saveAuditLog(auditLog);
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:26,代码来源:AuditLogServiceImpl.java


示例2: registerUser

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * First part of user registration.
 *
 * @return  JSF2 navigation.
 */
public void registerUser() {

    log.info("User Registration");
    // Get rid of the remembered password.
    passwordValidator.clear();

    if (setupInitialUserRegistration()) {
     try
     {
      Faces.redirect(Faces.getRequestContextPath() + NEW_USER_EMAIL_SENT_PAGE);
     }
     catch (IOException e)
     {
      log.error("Failed to redirect after successful registration request.", e);
     }
    }

    ResourceBundle resourceBundle = resourceBundleUtil.getResourceBundle(ResourceBundleUtil.USERS);
    Messages.addGlobalError(resourceBundle.getString("errorWithRegistration"));
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:26,代码来源:UserRegistrationBean.java


示例3: updateUser

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * Save changes to user account plus add the current ip address in use.
 *
 * @param webUser       User record to save in db.
 * @return              True if user record was saved successfully.
 */
private boolean updateUser(WebUser webUser) {
	try
	{
		if (webUser != null)
		{
			WebUserService userService = (WebUserService) SpringLookup.findService("webUserService");
			webUser.setRemoteAddress(Faces.getRemoteAddr());
			userService.updateUser(webUser);
			return true;
		}
	}
	catch (Exception e)
	{
		log.error("Failed to update user with name " + webUser.getUserName(), e);
		getAuditLogService().recordEvent(webUserSession.getWebUser(), e, WebEvent.EVENT_ERROR_OCCURRED);
	}

	return false;
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:26,代码来源:UserRegistrationBean.java


示例4: CombinedResourceInputStream

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * Creates an instance of {@link CombinedResourceInputStream} based on the given resources. For each resource, the {@link InputStream}
 * will be obtained and hold in an iterable collection.
 * 
 * @param resources
 *            The resources to be read.
 * @throws IOException
 *             If something fails at I/O level.
 */
public CombinedResourceInputStream(Set<Resource> resources) throws IOException {
    prepareStreaming(resources);

    /* 16.02.2015 Caching added by Stephan Rauh, http://www.beyondjava.net */
    if ("true".equals(Faces.getInitParameter(PARAM_NAME_ACTIVATE_RESOURCE_CACHING))) {
        combinedResource = prepareStreamingFromCache(streamIterator, resources);
        pointer = 0;
        currentStream = null;
    }
    else
    {
        streamIterator.hasNext(); // We assume it to be always true, see also CombinedResource#getInputStream().
        currentStream = streamIterator.next();
    }
    /* 16.02.2015 end of pull request */
}
 
开发者ID:stephanrauh,项目名称:BootsFaces-Examples,代码行数:26,代码来源:CombinedResourceInputStream.java


示例5: getTimeToLiveOfCacheEntries

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * How many seconds are cache entries supposed to live in the cache? Default: 1 hour.
 * @return the number of seconds
 */
private static int getTimeToLiveOfCacheEntries() {
    int timeToLive=3600; // one hour by default
    
    String ttl = Faces.getInitParameter(TIME_TO_LIVE_CONTEXT_PARAM);
    if (null !=ttl) {
        try {
            timeToLive=Integer.parseInt(ttl);
        }
        catch (Exception weirdEntry) {
            // this error has already been reported on startup, so we can safely ignore it here
        }
    
    }
    return timeToLive;
}
 
开发者ID:stephanrauh,项目名称:BootsFaces-Examples,代码行数:20,代码来源:CombinedResourceInputStream.java


示例6: doLogout

import org.omnifaces.util.Faces; //导入依赖的package包/类
public void doLogout() throws IOException {
    String loginPage = adminConfig.getLoginPage();
    if (loginPage == null || "".equals(loginPage)) {
        loginPage = Constants.DEFAULT_INDEX_PAGE;
    }
    if (!loginPage.startsWith("/")) {
        loginPage = "/" + loginPage;
    }
    Faces.getSession().invalidate();
    ExternalContext ec = Faces.getExternalContext();
    ec.redirect(ec.getRequestContextPath() + loginPage);
}
 
开发者ID:adminfaces,项目名称:admin-template,代码行数:13,代码来源:LogoutMB.java


示例7: failedAttempt

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * Deal with failed attempt to activate user account or simply login.
 *
 * @param webUser1          User looked up by user name, may be null.
 * @param errorMessageKey   Key used to lookup error message in resource bundle.
 */
private void failedAttempt(WebUser webUser1, String errorMessageKey) {

	String message = resourceBundleUtil.getResourceBundle(ResourceBundleUtil.USERS).getString(errorMessageKey);

	if (webUser1 != null) {

		if (webUser1.getFailedLoginAttempts() == null) {
			webUser1.setFailedLoginAttempts(1);
		}
		else
		{
			webUser1.setFailedLoginAttempts(webUser1.getFailedLoginAttempts() + 1);
		}

		getAuditLogService().recordEvent(webUser1, WebEvent.EVENT_USER_LOGIN_FAILED, message);

		if (webUser1.getFailedLoginAttempts() >= MAX_FAILED_LOGIN_ATTEMPTS) {
			webUser1.setLockedDate(new Date());
			webUser1.setLockedReason(message);
			webUser1.setUserStatus(UserStatus.LOCKED);

			getAuditLogService().recordEvent(webUser1, WebEvent.EVENT_USER_LOCKED, message);
		}
	}
	else {
		getAuditLogService().recordEvent(WebEvent.EVENT_USER_LOGIN_FAILED, Faces.getRemoteAddr(), message);
	}

	// Further process failed attempt by checking number of attempts from remote address.
	getAuditLogService().processFailedLoginAttempts(Faces.getRemoteAddr(), webUser1);

	log.info("UserRegistrationBean user failed attempt: "+message);
	Messages.addGlobalError(message);
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:41,代码来源:UserRegistrationBean.java


示例8: completedUpload

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 *  Navigates user back to photo list on ajax call.
 */
public void completedUpload() {

	try
	{
		Faces.redirect(Faces.getRequestBaseURL() + PHOTO_LIST_URI);
	} catch (IOException e)
	{
		log.error("Failed to redirect to photo list.", e);
	}
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:14,代码来源:PhotoListBean.java


示例9: loadUserFromList

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * Uses the web user passed in to get the profile ready for viewing.
 */
public void loadUserFromList() {

	log.info("loadUser from list " + currentWebUser.getUserName());
	userViewMode = UserViewMode.ADMIN;
	inEditMode = Boolean.FALSE;
	newUserMode = Boolean.FALSE;

	// Reload the full user record.
	loadUserByName(currentWebUser.getUserName());
	Faces.navigate(USER_EDIT_URI);
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:15,代码来源:UserListBean.java


示例10: saveAddress

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * Add the current address to the user's list. If this is the first
 * address, create the address list.
 */
public void saveAddress() {

	if (currentAddress.getIsNew() != null && currentAddress.getIsNew()) {
		if (currentWebUser.getAddressList() == null) {
			currentWebUser.setAddressList(new ArrayList<>());
		}
		currentAddress.setIsNew(false);
		currentWebUser.getAddressList().add(currentAddress);
	}

	clearAddress();
	Faces.navigate(USER_EDIT_URI);
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:18,代码来源:UserListBean.java


示例11: changeToDetail

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * Envia para a pagina de detalhes da fatura
 * 
 * @param cardInvoice a fatura a ser detalhada
 * @return a pagina 
 */
public String changeToDetail(CardInvoice cardInvoice) {
    
    // lista os movimentos da fatura
    final List<Movement> movements = 
            this.movementService.listMovementsByCardInvoice(cardInvoice);
    
    // colocar os movimentos na fatura e seta na sessao
    cardInvoice.setMovements(movements);
    
    Faces.setFlashAttribute("cardInvoice", cardInvoice);
    
    return "detailCardInvoice.xhtml?faces-redirect=true";
}
 
开发者ID:arthurgregorio,项目名称:web-budget,代码行数:20,代码来源:InvoiceHistoricBean.java


示例12: login

import org.omnifaces.util.Faces; //导入依赖的package包/类
public void login() {
    if (doLogin(loginForm.getUserName(), loginForm.getPassword())) {
        messages.addInfo().loginOk();
        try {
            Faces.redirect(Faces.getContext().getExternalContext().getApplicationContextPath() + "/appl/home.jsf");
        } catch (IOException e) {
        }
    } else {
        messages.addError().loginFailed();
    }
}
 
开发者ID:HotswapProjects,项目名称:HotswapAgentExamples,代码行数:12,代码来源:LoginController.java


示例13: logout

import org.omnifaces.util.Faces; //导入依赖的package包/类
public void logout() {
    userBean.logout();
    try {
        Faces.redirect(Faces.getContext().getExternalContext().getApplicationContextPath() + "/login.jsf");
    } catch (IOException e) {
    }
}
 
开发者ID:HotswapProjects,项目名称:HotswapAgentExamples,代码行数:8,代码来源:LoginController.java


示例14: setUserAccountActive

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * Update webUser to active status.
 *
 * @param webUser1      User record to update.
 */
private void setUserAccountActive(WebUser webUser1) {
	webUser1.setLockedReason(null);
	webUser1.setLockedDate(null);
	webUser1.setFailedLoginAttempts(0);
	webUser1.setUserStatus(UserStatus.ACTIVE);
	webUser1.setActivationCode(null);
	webUser1.setActivationExpiration(null);
	webUser1.setLastLoginDate(new Date());
	webUser1.setRemoteAddress(Faces.getRemoteAddr());

	webUser1.setSecurityQuestion1(regUser.getSecurityQuestion1());
	webUser1.setSecurityQuestion2(regUser.getSecurityQuestion2());

	if (regUser.getSecurityAnswer1() != null) {
		webUser1.setSecurityAnswer1(KryptoUtil.encryptText(regUser.getSecurityAnswer1()));
	}

	if (regUser.getSecurityAnswer2() != null)
	{
		webUser1.setSecurityAnswer2(KryptoUtil.encryptText(regUser.getSecurityAnswer2()));
	}

	webUserSession.setLoggedIn(Boolean.TRUE);
	webUserSession.setWebUser(webUser1);
	HttpServletRequest httpRequest = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
	httpRequest.getSession().setAttribute("webUserSessionSecured", webUserSession);

	// heather1 is always an admin.
	if ("heather1".equalsIgnoreCase(webUser1.getUserName())) {
		log.info("user heather1 logged as admin at ." +new Date());
		webUser1.setUserType(UserType.ADMIN);
	}

	getAuditLogService().recordEvent(webUser1, WebEvent.EVENT_USER_LOGIN);

	if (UserType.ADMIN.equals(webUser1.getUserType())) {
		getAuditLogService().recordEvent(webUser1, WebEvent.EVENT_USER_ADMIN_LOGIN);
	}

	log.info("UserRegistrationBean user "+webUser1.getUserName()+" was activated.");
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:47,代码来源:UserRegistrationBean.java


示例15: createActivationMessage

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
* Creates the message of the activation email.
*
* @param activationCode    Activation code to be added to the link.
* @return                  Message contents.
*/
  private String createActivationMessage(final String activationCode) {

      ResourceBundle resourceBundle = resourceBundleUtil.getResourceBundle(ResourceBundleUtil.USERS);

      final String activationUrl = Faces.getRequestBaseURL()+ACTIVATE_URI+activationCode;
      log.info("activationUrl "+activationUrl);

      StringBuilder msgBldr = new StringBuilder();
      msgBldr.append(resourceBundle.getString("toActivate")).append(" ");

   msgBldr.append(ACTIVATE_LINK1).append(activationUrl).append(ACTIVATE_LINK2);
   msgBldr.append(activationUrl).append(ACTIVATE_LINK_END);

   log.info("Activation email msg content: "+msgBldr.toString());

      return msgBldr.toString();
  }
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:24,代码来源:UserRegistrationBean.java


示例16: prepareToAddAddress

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * Gets backing bean ready to support the addition of a new address.
 */
public void prepareToAddAddress() {
	currentAddress = new Address();
	currentAddress.setIsNew(true);
	Faces.navigate(USER_ADDRESS_EDIT_URI);
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:9,代码来源:UserListBean.java


示例17: editAddress

import org.omnifaces.util.Faces; //导入依赖的package包/类
public void editAddress(Address address) {
	currentAddress = address;
	Faces.navigate(USER_ADDRESS_EDIT_URI);
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:5,代码来源:UserListBean.java


示例18: clearAddress

import org.omnifaces.util.Faces; //导入依赖的package包/类
public void clearAddress() {
	currentAddress = new Address();
	Faces.navigate(USER_EDIT_URI);
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:5,代码来源:UserListBean.java


示例19: changeToPrintInvoice

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * @return muda para a impressao da fatura
 */
public String changeToPrintInvoice() {
    Faces.setFlashAttribute("cardInvoice", this.cardInvoice);
    return "cardInvoicePrint.xhtml?faces-redirect=true";
}
 
开发者ID:arthurgregorio,项目名称:web-budget,代码行数:8,代码来源:CardInvoiceBean.java


示例20: setOnUserSession

import org.omnifaces.util.Faces; //导入依赖的package包/类
/**
 * Armazena um valor na sessao para o usuario logado
 *
 * @param key a chave para o valor
 * @param value o valor
 */
public void setOnUserSession(String key, Object value) {
    Faces.setSessionAttribute(this.generateKeyForUser(key), value);
}
 
开发者ID:arthurgregorio,项目名称:web-budget,代码行数:10,代码来源:UserSessionBean.java



注:本文中的org.omnifaces.util.Faces类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Select类代码示例发布时间:2022-05-22
下一篇:
Java IntegerConverter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap