Mike Thunder Mike Thunder - 3 months ago 7
Java Question

How to change the label of button after you login

I'm working on a school project in Java. I'm able to login user successfully who registered. But when he/she loged-in how can I hide Login and Register page link and replace them with MyAlumni. And after sign-out how can I show them again.
Here is the coding of my links on MasterPage

<td id="menucontainer" align="center">
<br>
<button id="homeBtn" onclick="window.location.href='Main.do'"></button>
<br>
<button id="loginBtn" onclick="window.location.href='ForwardGeneralAction.do?page=Login'"></button>
<br>
<button id="signupBtn" onclick="window.location.href='ForwardGeneralAction.do?page=SignUp'"></button>
<br>
<button id="helpBtn" onclick="window.location.href='ForwardGeneralAction.do?page=Help'"></button>
<br>
<button id="contactBtn" onclick="window.location.href='ForwardGeneralAction.do?page=Contact'"></button>
<br>


Please explain me step by step what I have to do. Many thanks

Answer

Most of the time, site will have a login.master to handle the login stuff, and like a site.master or default.master to handle the rest of it. I would suggest this in your case, too. You'd just put the login/register menu in login.master, and then the other menu in site.master.

In response to your comment, wherever your current master page is, add another one (right click, add, new item, master page) and copy the header type stuff from your other master page (sorry, I haven't done any web dev in java so I don't know the exact syntax)

And then your login master page (at least the menu part of it) will look like this:

<td id="menucontainer" align="center">
                    <br>
<button id="homeBtn" onclick="window.location.href='Main.do'"></button>
<br>
<button id="loginBtn" onclick="window.location.href='ForwardGeneralAction.do?page=Login'"></button>
<br>
<button id="signupBtn" onclick="window.location.href='ForwardGeneralAction.do?page=SignUp'"></button>

and then your other master page (the menu part) will look like this:

<td id="menucontainer" align="center">
                    <br>
<button id="homeBtn" onclick="window.location.href='Main.do'"></button>
<br>
<button id="alumniBtn" onclick="window.location.href='MyAlumni.do'"></button>
<button id="helpBtn" onclick="window.location.href='ForwardGeneralAction.do?page=Help'"></button>
<br>
<button id="contactBtn" onclick="window.location.href='ForwardGeneralAction.do?page=Contact'"></button>

The rest of the master page stuff is up to you!

Comments