cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript 'Var with user info from alfresco' - question

fhomasp
Champ in-the-making
Champ in-the-making
Hey,

I have a question on how to retrieve info of the current user.  I had a temporary solution but it is completely inadequate and doesn't work very well either.  In fact it doesn't work at all like I meant.

A made a presentation template to apply to certain spaces which adds an URL with a few parameters.  The parameters are the users' first and last name, which is passed to a custom bean with JSF page.
I'll add the code momentarily.
The parameter gets the first and last name from the name of the space, or at least that's what I wanted to try for temporary solution.  It would of course be much better to get the current user and add his/her first and lastname to the path.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Adjust CV</title><script language="JavaScript" type="text/javascript">var ch=space.children;for(var i=0; i<ch.length;i++){  if(ch[i].isContainer)  {function createURL(){location.href="/Alf_CV/jsp/personal.jsf?username="+ch[i];}}}</script></head><body><a href="javascript:createURL()"> Adjust CV </a></body></html>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

This creates the url but there seems to be something wrong with the var.  If I'd be able to get the last and first name from the context, that would be great.
And also note that there is a link to an external page.  This is also temporary.  I'm also working on getting the page inside the alfresco.war with the bean class in a .jar file working with the current session.  However the whole bean thing is still in development so for debugging and fast adjusting purpose I'm working like this.

Thanks for any insights on the matter Smiley Happy
1 REPLY 1

fhomasp
Champ in-the-making
Champ in-the-making
This won't work either.  The link is just not followable.
For testing purposes I tried to print some info to the output area, which won't work either. 
Perhaps a certain few std variables or properties won't work with a presentation template applied as custom view?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Adjust CV</title><script language="JavaScript" type="text/javascript">var ch=space.children;var name2 = userhome.properties["name"];  function createURL() {var name1 = userhome.properties.name;println("test");println(name1);println(name2);location.href="/Alf_CV/jsp/personal.jsf?username="+name2;}</script></head><body><a href="javascript:createURL()"> Adjust CV </a></body></html>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

edit:
Some extra notes.  The link works if I remove the var at the end of the url.  If I hardcode a name it'll also work but that's an even bigger nono than the current solution Smiley Happy