liferay 中的经常使用的

com.liferay.portal.kernel.language.LanguageUtil;
com.liferay.portal.kernel.util.StringPool;
com.liferay.portal.model.User;
com.liferay.portal.service.ServiceContext;
com.liferay.portal.service.UserLocalServiceUtil;
com.liferay.portal.theme.ThemeDisplay;
com.liferay.portlet.PortletURLImpl;
com.liferay.portal.kernel.servlet.SessionMessages;

//add liferay user
User liferayUser = UserLocalServiceUtil.addUser(user.getUserId(), user
				.getCompanyId(), false, map.get("pwd").toString(), map.get(
				"pwd").toString(), false, map.get("screenName").toString(), 
				map.get("email").toString(),
				StringPool.BLANK, locale, map.get("surName").toString(), "",
				map.get("givenName").toString(), 0, 0, true, birthdayMonth,
				birthdayDay, birthdayYear, StringPool.BLANK, null, null, null,
				null, false, serviceContext);

引用
1.liferay主题vm文件的国际化:
是从资源文件(language_zh_CN.propertise)中读取.vm文件中调用
$languageUtil.get($company_id, $locale, "str")
其中str是在资源文件中定义的str="xxx"
2.SessionMessages.add(request, "request_processed");成功提示信息


public void processAction(ActionMapping mapping, ActionForm form,
			PortletConfig portletConfig, ActionRequest actionRequest,
			ActionResponse actionResponse) throws Exception {
		
		downloadFile(actionRequest,actionResponse);
                  //在processAction中使用此句话后不在走向render
		setForward(actionRequest, ActionConstants.COMMON_NULL);
	}
/**
	 * 下载文件方法
	 * @param renderRequest
	 * @param renderResponse
	 * @throws SQLException
	 * @throws IOException
	 */
	private void downloadFile(ActionRequest renderRequest,
			ActionResponse renderResponse) throws SQLException, IOException {
		String ccno = renderRequest.getParameter("ccno");
		CustContract cc = new CustContract();
		cc = PortletActionBeanProxy.getInstance().
			getCustContractSvc().getCustContractById(
					Integer.parseInt(ccno));
		
		//TODO 下载文件
	
		Blob conFile = cc.getConFile();
		try {
			HttpServletResponse response = PortalUtil
						.getHttpServletResponse(renderResponse);
	
			byte[] bytes = new byte[(int)conFile.length()];
			conFile.getBinaryStream().read(bytes, 0, bytes.length);
			if (bytes != null && bytes.length > 0) {
				ServletResponseUtil.sendFile(
						response, "download_file",bytes);
			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

删除
<portlet:renderURL windowState="maximized" var="delete_url">
		<portlet:param name="struts_action" value="/erp/pay" />
		<portlet:param name="accaId" value="<%= ap.getAccaId().toString() %>" />
		<portlet:param name="flag" value="delete" />
</portlet:renderURL>
<%
String deleteUrl = "javascript:deleteInfo('" + HttpUtil.encodeURL(delete_url) + "')";
%>
<liferay-ui:icon image="delete" message="erp.button.value.delete" url="<%=deleteUrl %>" />

你可能感兴趣的:(JavaScript,qq,servlet,敏捷开发,咨询)