Get currently logged in user's name.

Need help? Post your questions here.

Moderator: moderators

Get currently logged in user's name.

Postby jon42689 » Thu Oct 25, 2012 3:42 pm

Hello all,

I've got a subsonic 4.7b3 install that I'm working on making some modifications on. I am trying to modify the dashboard page (my version of the 'home.jsp') to greet the user with their username when they visit the page. I'm tempted to upgrade the install, but I doubt it would make a difference here, and I'm not going to do it just for this to work.


${model.user.username} returns null. Is there something missing here, or is there another way to get this data? I see that's where the logout button normally gets the username.

I also tried something like

Code: Select all
<h1>Hi, <script type="text/javascript">
            var nameCurrentUser = "";
            var StealUser = "<fmt:message key='top.logout'><fmt:param value='${model.user.username}'/></fmt:message>";
            var foundUser = StealUser.replace("Log out ", nameCurrentUser);
            
               document.write("<font>" + foundUser);
               document.write("</font>");
            
            </script>   
</h1>


to try to steal the username from the logout message... That also returns null, so I suspect that it's not my code that's the problem. It appears the ${model.user.username} key can't be called from the main window? I'm not super comfortable with Java, but this seemed like it should be straightforward.

Anyone run into this before?

Thanks!!

**EDIT**

It works on the left pane also, so it has to be something that's different in the main window.
jon42689
 
Posts: 4
Joined: Thu Oct 25, 2012 3:33 pm

Re: Get currently logged in user's name.

Postby hakko » Thu Oct 25, 2012 4:14 pm

You can only access data that has been passed by the corresponding Controller Java class.
For top.view, parameters passed by TopController.java.
For left.view, parameters passed by LeftController.java.
And for main.view, parameters, passed by MainController.java. To get custom data into main.jsp, you'd have to explicitly pass it from MainController.java.
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: Get currently logged in user's name.

Postby jon42689 » Fri Oct 26, 2012 9:03 pm

That's what I was expecting. Obviously the classes are just compiled blobs, so no editing can be done there.

If I wanted to modify the source, what would I use to compile it? I'm primarily a PHP guy, so I'm not used to having to compile all the time. I'd like to also learn how to properly use revision management software also.

I'm looking to do some playing around, both to learn the language better, and also to change some things about the software.

Anyone do Java development who could recommend me a toolchain for this?
jon42689
 
Posts: 4
Joined: Thu Oct 25, 2012 3:33 pm

Re: Get currently logged in user's name.

Postby hakko » Sat Oct 27, 2012 4:56 am

You build it using Maven, and development gets easier if you use an IDE like Eclipse or IntelliJ. It would probably be more useful to learn Git for revision management than to learn Subversion which Subsonic uses.
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: Get currently logged in user's name.

Postby jon42689 » Sat Oct 27, 2012 3:31 pm

This is what I was looking for. Looks like I have a lot of learning to do.

I'll search around and see if I can find some top-down view of the process, because I'm still a little unclear as to what the steps would be.
jon42689
 
Posts: 4
Joined: Thu Oct 25, 2012 3:33 pm

Re: Get currently logged in user's name.

Postby hakko » Sat Oct 27, 2012 9:37 pm

I don't know if there's a guide on how to get started. I just grabbed the code and started changing it. It might be worth posting a new topic and hear if anyone has some written instructions.
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden


Return to Help

Who is online

Users browsing this forum: No registered users and 24 guests