0

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?

Rasabihari Kumar
  • 491
  • 1
  • 4
  • 16
stackoverflow user
  • 313
  • 1
  • 5
  • 20

4 Answers4

1

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.

Community
  • 1
  • 1
Rasabihari Kumar
  • 491
  • 1
  • 4
  • 16
0

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.

yannicuLar
  • 3,083
  • 3
  • 32
  • 50
0

Type this in your java code:

String userId=ParamUtil.getString(portletRequest, param);
Jennis Vaishnav
  • 331
  • 7
  • 29
0

On your java code use,

get ThemeDisplay from the request(actionRequest) and get userid from themeDisplay.getUserId()

Pandey
  • 1
  • 1