Laliwala IT Services

Laliwala IT Services
Website Development

Saturday, February 19, 2011

javascript, jquery, java code, liferay jquery, liferay javascript, liferay translate, liferay id, liferay screen, liferay text, liferay format, lifera

Liferay Portal Development

Liferay Portlet Tutorial
 
Liferay  Javascript Tutorial

Liferay Jquery Tutorial

Liferay Theme Display Get User Id

Liferay Get Screen Name


Justin                    Liferay Developer

Mastic                     :
                                           Hi everybody.
                                          
                                           I know there have been quite a few threads about this previously, but this particular issue didn't seem to come up.
                                          
                                           There is some Java code which appears to translate the currently logged in user's ID number to their screen name, but I need to be able to do this with Javascript or jquery (any way that can be embedded in the javascript text area found on the "Manage Page" page).
                                          
                                           Right now, I have "themeDisplay.getUserId()" which returns the userID properly, but I can't seem to get it into the screen name format that I need.
                                          
                                           Any help would be greatly appreciated! Thanks!
                                          
Mohd Hanafi          :          RE: Getting screen name from userID
                                          
                                           Could you try, themeDisplay.getscreenName()
                                          
                                           Thanks.
                                          
                                           Regards,
                                          
                                           Hanafi, KL.
                                          
Dhrutika Parekh      :          RE: Getting screen name from userID
                                          
                                           Hi,
                                          
                                           Use this to get screen name:themeDisplay.getUser().getScreenName();
                                          
                        Regards,

Dhrutika
                                          
Justin Mastic           :          RE: Getting screen name from userID
                                          
                                           I tried both themeDisplay.getscreenName() and themeDisplay.getUser().getScreenName(). Unfortunately neither of them work as it says that the object doesn't support the method.
                                          
                                           Are there any other methods that could be used here, or is there a way to find out why the themeDisplay object isn't able to call these methods?
                                          
VCVijayan MCA MBA    :    RE: Getting screen name from userID
                                          
                                           Hi,
                                          
                        Include liferay define objects.
                                          
VCVijayan MCA MBA    :    RE: Getting screen name from userID
                                          
                                           Hi Mohd,
                                          
                                          
                                          
                                           Use the above code.
                                          
                                           Note: Include liferay-theme.tld
                                          
Dhrutika Parekh      :          RE: Getting screen name from userID
                                          
                                           Hi ,
                                           I have never seen such issue.Using themedisplay you are able to get userid.then you should be able to get screenname also.
                                          
                                           Regards,
                                          
                                           Dhrutika
                                          
Justin Mastic           :          RE: Getting screen name from userID
                                          
                                           Thanks for the reply, but on which page do I enter:
                                          
                                          
                                          
                                           I'm still really new at all of this and I'm not entirely sure of where all this code should go. Thanks!
                                          
VCVijayan MCA MBA    :    RE: Getting screen name from userID
                                          
                                           Hi,
                                          
                                           Incude the following code in the init.jsp file. If your are not using that file place the code where you are using the screen name.
                                          
                                          
                                           Use the following code to get the screen name.
                                          
                                          
                                          
Justin Mastic           :          Did I add these lines to the correct file?
                                          
                                           Since this is for the web proxy porlet, I added your two lines to /html/portlet/web_proxy/init.jsp, restarted my tomcat server, and still no change. themeDisplay.getUser().getScreenName() still throws a "method not supported" error.
                                          
VCVijayan MCA MBA    :    Hi Justin Mastic,
                                          
                                           In which file you are trying to fetch screenName. It is Jsp or Java file.
                                          
                                           If it is Jsp, check whether you included "init.jsp" in your file where you are trying to access screenName.
                                          
                                           If not reply me i will provide you the code for java file.
                                          
Pranay R Patadiya :          RE: Getting screen name from userID
                                          
                                           Hi Justin,
                                          
                                           First you should check r u getting themeDisplay object or not?
                                          
                                           In both jsp and java(if u have actionrequest obj), you can have this object.
                                          
                                           In JSP u need to include
                                          
                                          
                                           in init.jsp which u have included.
                                          
                                                                                                                                               
                                                                                                                                                     
                                                                                                                                                     
                                           In java file, You can get this object:                                                
                                                                                                                                                     
                                           Thanks,                                                                                             
                                                                                                                                                     
                                           Pranay Patadiya                                                                                
                                                                                                                                                     
Justin Mastic           :          Hi Justin Mastic,                                                                               
                                                                                                                                                     
                                           In which file you are trying to fetch screenName. It is Jsp or Java file.                                                                            
                                                                                                                                                     
                                           If it is Jsp, check whether you included "init.jsp" in your file where you are trying to access screenName.                                                                                                                            
                                                                                                                                                     
                                           If not reply me i will provide you the code for java file.                                                
                                                                                                                                                     
                                           am attempting to get the screenName from the javascript option on the Manage Pages area. I'm not editing any jsp or java files (I wouldn't be opposed to it, but if I can do it from javascript I'd like to do it there). Really, the only reason I am doing this is because I don't have an extension environment set up on my computer, which I'm told is necessary to edit those files. So I'm doing what I can with what I have available.                                                                                                                                                                            
                                                                                                                                                     
                                           Here is the code I am putting into "Javascript 1" on Manage Pages:                                                                                
                                                                     
                                                                                                                                                     
                                                                                                                                                     
                                           I am attempting to take the screen name of the logged in user, and passing it to a text field called "userid" on a page on another server through the web proxy portlet. Right now, it DOES push the userID through correctly, but I need the screen name to do what I want.                                             
                                                                                                                                                     
Justin Mastic           :          Hi Justin,                                                                                          
                                                                                                                                                     
                                           First you should check r u getting themeDisplay object or not?                                                
                                                                                                                                                     
                                           In both jsp and java(if u have actionrequest obj), you can have this object.                                                                                
                                                                                                                                                     
                                           In JSP u need to include                                                                  
                                                                     
                                                                                                                                                     
                                                                                                                                                     
                                           in init.jsp which u have included.                                                     
                                                                                                                                                     
                                           In java file, You can get this object:                                                
                                                                     
                                                                                                                                                     
                                           Thanks,                                                                                             
                                                                                                                                                     
                                           Pranay Patadiya                                                                                
                                                                                                                                                     
Mazhar Anwar        :          Hey Justin,                                                                                        
                                                                                                                                                     
                        ThemeDisplay Object in jsp/java and javascript are different.

for getting screen name using themeDisplay in javascript you need to modify portal jsp which is in Portal source portal-web/docroot/html/common/themes/top_js.jspf                                                            
                                                                                                                                                     
                                           at line number 100 - 180.                                                                  
                                                                                                                                                     
                                           You can override top_js.jspf in Extension Environment.                                                           
                                                                                                                                                     
                        ThemeDisplay: {

getCompanyId: function() {

return "<%= themeDisplay.getCompanyId() %>";

},                                                                                                                                                        
                                                                                                                                                     
                        etUserId: function() {

return "<%= themeDisplay.getUserId() %>";

},                                                                                                                                                        
                        <c:if test="<%= themeDisplay.isSignedIn() %>">

getUserName: function() {

return "<%= UnicodeFormatter.toString(user.getFullName()) %>";

},

</c:if>

....

.....

......

.......                                                                                                                                                    
                                                                                                                                                     
                                           You need to add one more method as follows,                               
                                                                                                                                                     
                        <c:if test="<%= themeDisplay.isSignedIn() %>">

getScreenName: function() {

return "<%= UnicodeFormatter.toString(user.getScreenName()) %>";

},

</c:if>                                                                                                                                       
                                                                                                                                                     
                        And then it will be available in javascript as themeDisplay.getScreenName().

Hope it will help you.                                                                                                                             
                                                                                                                                                     
Justin Mastic           :          Mazhar:                                                                                             
                                                                                                                                                     
                                           I believe that is EXACTLY what I needed. I am able to use themeDisplay.getScreenName() now without a problem. Thank you so much! Your help is greatly appreciated!                                                                                                                                                                         
                                                                                                                                                     

No comments:

Post a Comment