Reputation: 313
I am using Liferay 6.1.1.
I have created a portlet with <aui:form>
having two text fields and a button.
On submit I want to know the userId who submitted the below form:
<aui:form action="<%=myUrl%>" method="post">
<aui:input type="text" name="name"></aui:input>
<aui:input type="text" name="addr"></aui:input>
<aui:button type="submit" value="save"></aui:button>
</aui:form>
How can I get the userId?
Upvotes: 0
Views: 408
Reputation: 1
On your java code use,
get ThemeDisplay from the request(actionRequest) and get userid from themeDisplay.getUserId()
Upvotes: 0
Reputation: 341
Type this in your java code:
String userId=ParamUtil.getString(portletRequest, param);
Upvotes: 0
Reputation: 3133
You can use the PortalUtil. On the Controler side :
User user = PortalUtil.getUser(actionRequest)
in your jsp :
User user = PortalUtil.getUser(renderRequest);
Don't forget to handle exceptions, or user being not null.
Upvotes: 0
Reputation: 491
I hope the Users are login into your portal before you show them this form.
If yes than you can look at the answers of this question which show a JSR-286 specific way and a liferay specific way to get the UserId
.
And if you are showing this form and letting guest users i.e. any anonymous person to submit this form, then obviously you can't get the UserId
.
Upvotes: 1