java - Insert value in textfield - struts2+liferay -


in jsp have code:

.....     // userid     long userid = com.liferay.portal.util.portalutil.getuserid(request);     string username = com.liferay.portal.util.portalutil.getusername(userid , "guest");     %>       <s:textfield name="user" value="<%=username%>"></s:textfield> 

i not able display in textfield username value.

can me,please. thanks.

scriptlets not allowed use struts tags. , cannot access the scripting variable username because it's not on value stack. make available create new variable in value stack has value of scripting variable.

<s:set var="username"><%=username%></s:set> <s:textfield name="user" value="%{#username}"/>  

another approach not expected make use of known containers request accessible struts tags.

<% request.setattribute("username", username); %> <s:textfield name="user" value="%{#request.username}"/> 

you may notice difference in first example new variable created , scripting variable passed value string printed out. in second example scripting variable passed reference.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -