本文整理匯總了Java中javax.portlet.PortletRequest.getAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java PortletRequest.getAttribute方法的具體用法?Java PortletRequest.getAttribute怎麽用?Java PortletRequest.getAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.portlet.PortletRequest
的用法示例。
在下文中一共展示了PortletRequest.getAttribute方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLayoutByFriendlyURL
import javax.portlet.PortletRequest; //導入方法依賴的package包/類
/**
* Get layout by friendlyurl.
*
* @param resourceRequest
* @return layout
* @throws PortalException if layout is not found
*/
public static Layout getLayoutByFriendlyURL(
PortletRequest portletRequest, String layoutFriendlyURL)
throws PortalException {
ThemeDisplay themeDisplay =
(ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
if (layoutFriendlyURL != null) {
return LayoutLocalServiceUtil.getFriendlyURLLayout(
themeDisplay.getScopeGroupId(),
themeDisplay.getLayout().isPrivateLayout(), layoutFriendlyURL);
}
throw new PortalException(
"Couldn't find asset publisher layout for " + layoutFriendlyURL +
". Please check configuration.");
}
示例2: getAssetViewURL
import javax.portlet.PortletRequest; //導入方法依賴的package包/類
/**
* Gets the search result's view URL
*
* @param document The searched document
* @param request The request
* @param response The response
* @param currentLayout The current page
* @param tabId The search tab ID
*
* @return The search result URL
*/
private String getAssetViewURL(Document document, PortletRequest request, PortletResponse response, Layout currentLayout, String tabId, String keywords) {
String className = document.get(Field.ENTRY_CLASS_NAME);
long classPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));
String currentUrl = this.portal.getCurrentURL(request);
String returnedUrl;
if(ASSET_TYPE.equals(className) && classPK > 0) {
try {
String portletId = (String) request.getAttribute(WebKeys.PORTLET_ID);
PortletURL viewInPortletUrlObj = this.portletUrlFactory.create(request, portletId, currentLayout, LIFECYCLE_RENDER);
viewInPortletUrlObj.setParameter(PortletRequestParameter.VIEW_MODE.getName(), ViewMode.VIEW_JOURNAL.getParamValue());
viewInPortletUrlObj.setParameter(Field.ENTRY_CLASS_PK, Long.toString(classPK));
viewInPortletUrlObj.setParameter(PortletRequestParameter.TAB_ID.getName(), tabId);
viewInPortletUrlObj.setParameter(PortletRequestParameter.KEYWORDS.getName(), keywords);
String viewInPortletUrl = viewInPortletUrlObj.toString();
AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(className);
AssetRenderer<?> assetRenderer = assetRendererFactory.getAssetRenderer(classPK);
returnedUrl = assetRenderer.getURLViewInContext((LiferayPortletRequest) request, (LiferayPortletResponse) response, viewInPortletUrl);
} catch(Exception e) {
returnedUrl = currentUrl;
}
} else {
returnedUrl = currentUrl;
}
return returnedUrl;
}
示例3: setCharacterEncoding
import javax.portlet.PortletRequest; //導入方法依賴的package包/類
static public void setCharacterEncoding(
PortletRequest req,
String encoding)
{
UploadedFiles files = (UploadedFiles)
req.getAttribute(_UPLOADED_FILES_KEY);
_setCharacterEncoding(files, encoding);
}
示例4: getCurrentLayoutFriendlyURL
import javax.portlet.PortletRequest; //導入方法依賴的package包/類
/**
* Get current layout friendly URL
*
* @return String friendly URL for the current layout
* @throws PortalException
*/
public static String getCurrentLayoutFriendlyURL(PortletRequest portletRequest)
throws PortalException {
ThemeDisplay themeDisplay =
(ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
Layout selectedLayout =
LayoutLocalServiceUtil.getLayout(themeDisplay.getPlid());
return PortalUtil.getLayoutFriendlyURL(selectedLayout, themeDisplay);
}
示例5: buildCTQuery
import javax.portlet.PortletRequest; //導入方法依賴的package包/類
@Override
public BooleanQuery buildCTQuery(
PortletRequest portletRequest)
throws Exception {
if (portletRequest.getAttribute("userSegmentIds") == null) {
return null;
}
long[] userSegmentIds = (long[])portletRequest.getAttribute("userSegmentIds");
if (_log.isDebugEnabled()) {
_log.debug("Found " + userSegmentIds.length + " user segments.");
}
BooleanQuery query = new BooleanQueryImpl();
for (int i = 0; i < userSegmentIds.length; i++) {
long ctCategoryId = _userSegmentLocalService.getUserSegment(userSegmentIds[i]).getAssetCategoryId();
TermQuery condition = new TermQueryImpl(Field.ASSET_CATEGORY_IDS, String.valueOf(ctCategoryId));
query.add(condition, BooleanClauseOccur.SHOULD);
}
query.setBoost(_gSearchConfiguration.audienceTargetingBoost());
return query;
}
示例6: TaskRecordSearch
import javax.portlet.PortletRequest; //導入方法依賴的package包/類
public TaskRecordSearch(PortletRequest portletRequest, String curParam, PortletURL iteratorURL) {
super(portletRequest, new TaskRecordDisplayTerms(portletRequest), new TaskRecordSearchTerms(portletRequest),
curParam, DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
PortletConfig portletConfig = (PortletConfig) portletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
TaskRecordDisplayTerms displayTerms = (TaskRecordDisplayTerms) getDisplayTerms();
TaskRecordSearchTerms searchTerms = (TaskRecordSearchTerms) getSearchTerms();
String portletId = PortletProviderUtil.getPortletId(User.class.getName(), PortletProvider.Action.VIEW);
String portletName = portletConfig.getPortletName();
if (!portletId.equals(portletName)) {
displayTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
searchTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
}
iteratorURL.setParameter(TaskRecordDisplayTerms.TASKRECORDID, String.valueOf(displayTerms.getTaskRecordId()));
iteratorURL.setParameter(TaskRecordDisplayTerms.STATUS, String.valueOf(displayTerms.getStatus()));
iteratorURL.setParameter(TaskRecordDisplayTerms.WORK_PACKAGE, displayTerms.getWorkPackage());
iteratorURL.setParameter(TaskRecordDisplayTerms.DESCRIPTION, displayTerms.getDescription());
iteratorURL.setParameter(TaskRecordDisplayTerms.USER_NAME, displayTerms.getUserName());
iteratorURL.setParameter(TaskRecordDisplayTerms.TICKET_URL, displayTerms.getTicketURL());
iteratorURL.setParameter(TaskRecordDisplayTerms.CREATE_DATE, displayTerms.getCreateDate());
iteratorURL.setParameter(TaskRecordDisplayTerms.MODIFIED_DATE, displayTerms.getModifiedDate());
iteratorURL.setParameter(TaskRecordDisplayTerms.FROM_DATE, displayTerms.getFromDate());
iteratorURL.setParameter(TaskRecordDisplayTerms.UNTIL_DATE, displayTerms.getUntilDate());
iteratorURL.setParameter(TaskRecordDisplayTerms.DURATION, String.valueOf(displayTerms.getDuration()));
try {
PortalPreferences preferences = PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest);
String orderByCol = ParamUtil.getString(portletRequest, "orderByCol");
String orderByType = ParamUtil.getString(portletRequest, "orderByType");
if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) {
preferences.setValue(portletId, "task-records-order-by-col", orderByCol);
preferences.setValue(portletId, "task-records-order-by-type", orderByType);
} else {
orderByCol = preferences.getValue(portletId, "task-records-order-by-col", "modified-date");
orderByType = preferences.getValue(portletId, "task-records-order-by-type", "asc");
}
setOrderableHeaders(orderableHeaders);
if (Validator.isNotNull(orderableHeaders.get(orderByCol))) {
setOrderByCol(orderableHeaders.get(orderByCol));
} else {
_log.error(orderByCol + " is not an orderable header.");
setOrderByCol(orderByCol);
}
setOrderByType(orderByType);
} catch (Exception e) {
_log.error(e);
}
}
示例7: getTaskRecords
import javax.portlet.PortletRequest; //導入方法依賴的package包/類
protected List<TaskRecord> getTaskRecords(PortletRequest request) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
PortletURL iteratorURL = PortletURLFactoryUtil.create(request, PortletKeys.TIMETRACKER,
themeDisplay.getLayout(), PortletRequest.RENDER_PHASE);
String description = ParamUtil.getString(request, "description");
boolean advancedSearch = ParamUtil.getBoolean(request, "advancedSearch", false);
boolean andOperator = ParamUtil.getBoolean(request, "andOperator", true);
int end = ParamUtil.getInteger(request, "end");
boolean ignoreFromDate = ParamUtil.getBoolean(request, "ignoreFromDate");
Date fromDate = null;
if (!ignoreFromDate) {
int fromDateDay = ParamUtil.getInteger(request, "fromDateDay");
int fromDateMonth = ParamUtil.getInteger(request, "fromDateMonth");
int fromDateYear = ParamUtil.getInteger(request, "fromDateYear");
fromDate = PortalUtil.getDate(fromDateMonth, fromDateDay, fromDateYear);
}
String keywords = ParamUtil.getString(request, "keywords");
String orderByCol = ParamUtil.getString(request, "orderByCol", "modifiedDate");
String orderByType = ParamUtil.getString(request, "orderByType", "desc");
long ownerUserId = ParamUtil.getLong(request, "ownerUserId");
int start = ParamUtil.getInteger(request, "start");
int status = ParamUtil.getInteger(request, Field.STATUS);
TaskRecordSearch taskRecordSearch = new TaskRecordSearch(request, iteratorURL);
orderByCol = taskRecordSearch.getOrderByCol();
boolean ignoreUntilDate = ParamUtil.getBoolean(request, "ignoreUntilDate");
Date untilDate = null;
if (!ignoreUntilDate) {
int untilDateDay = ParamUtil.getInteger(request, "untilDateDay");
int untilDateMonth = ParamUtil.getInteger(request, "untilDateMonth");
int untilDateYear = ParamUtil.getInteger(request, "untilDateYear");
untilDate = PortalUtil.getDate(untilDateMonth, untilDateDay, untilDateYear);
}
String workPackage = ParamUtil.getString(request, "workPackage");
boolean reverse = "desc".equals(orderByType);
Sort sort = new Sort(orderByCol, reverse);
Hits hits = null;
if (advancedSearch) {
hits = TaskRecordServiceUtil.search(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), ownerUserId,
workPackage, description, status, fromDate, untilDate, null, andOperator, advancedSearch, start,
end, sort);
} else {
hits = TaskRecordServiceUtil.search(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), 0, keywords,
start, end, sort);
}
List<TaskRecord> taskRecords = TimetrackerUtil.getTaskRecords(hits);
return taskRecords;
}
示例8: ContactSearch
import javax.portlet.PortletRequest; //導入方法依賴的package包/類
public ContactSearch(PortletRequest portletRequest, String curParam, PortletURL iteratorURL) {
super(portletRequest, new ContactDisplayTerms(portletRequest), new ContactSearchTerms(portletRequest), curParam,
DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
PortletConfig portletConfig = (PortletConfig) portletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
ContactDisplayTerms displayTerms = (ContactDisplayTerms) getDisplayTerms();
ContactSearchTerms searchTerms = (ContactSearchTerms) getSearchTerms();
String portletId = PortletProviderUtil.getPortletId(User.class.getName(), PortletProvider.Action.VIEW);
String portletName = portletConfig.getPortletName();
if (!portletId.equals(portletName)) {
displayTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
searchTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
}
iteratorURL.setParameter(ContactDisplayTerms.COMPANY, String.valueOf(displayTerms.getCompany()));
iteratorURL.setParameter(ContactDisplayTerms.CONTACT_ID, String.valueOf(displayTerms.getContactId()));
iteratorURL.setParameter(ContactDisplayTerms.CREATE_DATE, String.valueOf(displayTerms.getCreateDate()));
iteratorURL.setParameter(ContactDisplayTerms.EMAIL, String.valueOf(displayTerms.getEmail()));
iteratorURL.setParameter(ContactDisplayTerms.FAX, String.valueOf(displayTerms.getFax()));
iteratorURL.setParameter(ContactDisplayTerms.FULL_NAME, String.valueOf(displayTerms.getFullName()));
// TODO: add default impp
iteratorURL.setParameter(ContactDisplayTerms.MODIFIED_DATE, String.valueOf(displayTerms.getModifiedDate()));
iteratorURL.setParameter(ContactDisplayTerms.NAME, String.valueOf(displayTerms.getName()));
iteratorURL.setParameter(ContactDisplayTerms.PHONE, String.valueOf(displayTerms.getPhone()));
iteratorURL.setParameter(ContactDisplayTerms.USER_NAME, String.valueOf(displayTerms.getUserName()));
try {
PortalPreferences preferences = PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest);
String orderByCol = ParamUtil.getString(portletRequest, "orderByCol");
String orderByType = ParamUtil.getString(portletRequest, "orderByType");
if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) {
preferences.setValue(portletId, "contacts-order-by-col", orderByCol);
preferences.setValue(portletId, "contacts-order-by-type", orderByType);
} else {
orderByCol = preferences.getValue(portletId, "contacts-order-by-col", "modified-date");
orderByType = preferences.getValue(portletId, "contacts-order-by-type", "asc");
}
setOrderableHeaders(orderableHeaders);
if (Validator.isNotNull(orderableHeaders.get(orderByCol))) {
setOrderByCol(orderableHeaders.get(orderByCol));
} else {
_log.error(orderByCol + " is not an orderable header.");
setOrderByCol(orderByCol);
}
setOrderByType(orderByType);
} catch (Exception e) {
_log.error(e);
}
}
示例9: getSuggestionsAsStringArray
import javax.portlet.PortletRequest; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public String[] getSuggestionsAsStringArray(
PortletRequest portletRequest)
throws Exception {
ThemeDisplay themeDisplay =
(ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
Locale locale = themeDisplay.getLocale();
String keywords =
ParamUtil.getString(portletRequest, GSearchWebKeys.KEYWORDS);
AggregateSuggester aggregateSuggester =
new AggregateSuggester(GSEARCH_SUGGESTION_NAME, keywords);
JSONArray configurationArray = JSONFactoryUtil.createJSONArray(_gSearchConfiguration.suggestConfiguration());
for (int i = 0; i < configurationArray.length(); i++) {
JSONObject item = configurationArray.getJSONObject(i);
String suggesterType = item.getString("suggesterType");
Suggester suggester = null;
if ("phrase".equals(suggesterType)) {
suggester = getPhraseSuggester(item, locale, keywords);
} else if ("completion".equals(suggesterType)) {
suggester = getCompletionSuggester(item, locale, keywords);
}
if (suggester != null) {
aggregateSuggester.addSuggester(suggester);
}
}
// Create searchcontext.
SearchContext searchContext = new SearchContext();
searchContext.setCompanyId(themeDisplay.getCompanyId());
// Build results JSON object.
List<String>suggestions = new ArrayList<String>();
SuggesterResults suggesters =
_querySuggester.suggest(searchContext, aggregateSuggester);
Collection<SuggesterResult> suggesterResults =
suggesters.getSuggesterResults();
if (suggesterResults != null) {
for (SuggesterResult suggesterResult : suggesterResults) {
for (Entry entry : suggesterResult.getEntries()) {
for (Option option : entry.getOptions()) {
if (_log.isDebugEnabled()) {
_log.debug("Adding suggestion:" + option.getText());
}
if (!suggestions.contains(option.getText())) {
suggestions.add(option.getText());
}
}
}
}
}
return suggestions.stream().toArray(String[]::new);
}
示例10: MeasurementSearch
import javax.portlet.PortletRequest; //導入方法依賴的package包/類
public MeasurementSearch(PortletRequest portletRequest, String curParam, PortletURL iteratorURL) {
super(portletRequest, new MeasurementDisplayTerms(portletRequest), new MeasurementSearchTerms(portletRequest),
curParam, DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
PortletConfig portletConfig = (PortletConfig) portletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
MeasurementDisplayTerms displayTerms = (MeasurementDisplayTerms) getDisplayTerms();
MeasurementSearchTerms searchTerms = (MeasurementSearchTerms) getSearchTerms();
String portletId = PortletProviderUtil.getPortletId(User.class.getName(), PortletProvider.Action.VIEW);
String portletName = portletConfig.getPortletName();
if (!portletId.equals(portletName)) {
displayTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
searchTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
}
iteratorURL.setParameter(MeasurementDisplayTerms.CREATE_DATE, displayTerms.getCreateDate());
iteratorURL.setParameter(MeasurementDisplayTerms.DATA, displayTerms.getData());
iteratorURL.setParameter(MeasurementDisplayTerms.MEASUREMENT_ID,
String.valueOf(displayTerms.getMeasurementId()));
iteratorURL.setParameter(MeasurementDisplayTerms.STATUS, String.valueOf(displayTerms.getStatus()));
iteratorURL.setParameter(MeasurementDisplayTerms.USER_NAME, displayTerms.getUserName());
iteratorURL.setParameter(MeasurementDisplayTerms.MODIFIED_DATE, displayTerms.getModifiedDate());
iteratorURL.setParameter(MeasurementDisplayTerms.FROM, String.valueOf(displayTerms.getFrom()));
iteratorURL.setParameter(MeasurementDisplayTerms.UNTIL, String.valueOf(displayTerms.getUntil()));
try {
PortalPreferences preferences = PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest);
String orderByCol = ParamUtil.getString(portletRequest, "orderByCol");
String orderByType = ParamUtil.getString(portletRequest, "orderByType");
if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) {
preferences.setValue(portletId, "measurements-order-by-col", orderByCol);
preferences.setValue(portletId, "measurements-order-by-type", orderByType);
} else {
orderByCol = preferences.getValue(portletId, "measurements-order-by-col", "modified-date");
orderByType = preferences.getValue(portletId, "measurements-order-by-type", "asc");
}
setOrderableHeaders(orderableHeaders);
if (Validator.isNotNull(orderableHeaders.get(orderByCol))) {
setOrderByCol(orderableHeaders.get(orderByCol));
} else {
_log.error(orderByCol + " is not an orderable header.");
setOrderByCol(orderByCol);
}
setOrderByType(orderByType);
} catch (Exception e) {
_log.error(e);
}
}