Fórumok

Getting request paremters from Services

thumbnail
Ray Augé, módosítva 14 év-val korábban

Getting request paremters from Services

Liferay Legend Bejegyzések: 1197 Csatlakozás dátuma: 2005.02.08. Legújabb bejegyzések
Hey All,

As of LPS-5826 all request parameters will be loaded into the ServiceContext attributes map.

This means that all these will be available from within services that use ServiceContext.

i.e. Want to add a form field to the User creation form?

Just add the field:



Later INSIDE
	public User addUser(
			long creatorUserId, long companyId, boolean autoPassword,
			String password1, String password2, boolean autoScreenName,
			String screenName, String emailAddress, String openId,
			Locale locale, String firstName, String middleName, String lastName,
			int prefixId, int suffixId, boolean male, int birthdayMonth,
			int birthdayDay, int birthdayYear, String jobTitle, long[] groupIds,
			long[] organizationIds, long[] roleIds, long[] userGroupIds,
			boolean sendEmail, ServiceContext serviceContext)
		throws PortalException, SystemException {
                ...


Do this:

  
               ...
               Serializable param = serviceContext.getAttribute("myCustomField"); 
               ...


That's it!
thumbnail
Julio Camarero, módosítva 14 év-val korábban

RE: Getting request paremters from Services

Liferay Legend Bejegyzések: 1668 Csatlakozás dátuma: 2008.07.15. Legújabb bejegyzések
Great idea Ray! emoticon

This is very simple and easy to use.....

We have to add a method to LocalizationUtil to get a localized field from the serviceContext (instead of the request) to allow localized fields in the forms.