Page 1 of 1

Get currently logged in user's name.

PostPosted: Thu Oct 25, 2012 3:42 pm
by jon42689
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.

Re: Get currently logged in user's name.

PostPosted: Thu Oct 25, 2012 4:14 pm
by hakko
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.

Re: Get currently logged in user's name.

PostPosted: Fri Oct 26, 2012 9:03 pm
by jon42689
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?

Re: Get currently logged in user's name.

PostPosted: Sat Oct 27, 2012 4:56 am
by hakko
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.

Re: Get currently logged in user's name.

PostPosted: Sat Oct 27, 2012 3:31 pm
by jon42689
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.

Re: Get currently logged in user's name.

PostPosted: Sat Oct 27, 2012 9:37 pm
by hakko
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.