Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
it's my first time in development field and i'm really stuck -_-
I'm developing a java application using netbeans IDE 7.4. I created all my frames and they are all working. I have a table in my database named (user) contains one username and password(i'm using mysql with wampserver) the activation of all the interfaces comes after the identification . now i want to add another user with limited privileges(can't use some buttons) how is it possible to do that? Do i have to create two versions of every frame for each user? and how to connect them to the database?
I would handle this with a function being called right after logging in (identification). Essentially an authorize privileges function that will enable/disable buttons accordingly.
Example,
private void authPrivs(userLevel)
{
switch(userLevel)
case "Admin":
break;
case "Limited":
buttonAdmin.setEnabled(false);
buttonAdmin2.setEnabled(false);
break;
}
Because you have already designed the GUI with admin privileges defaulted, enabling is not necessary in the switch statement. You could even make the buttons disappear with setVisible(), but that might make your GUI really ugly.
Edit: Just to clarify, I would suggest making a field in your database that stores the "userLevel" variable. Once your user logs in, pull that userLevel off his login, and pass it to authPrivs().
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have an application using php backend. Let's say this is an app for cheating views on YouTube, or something else where points are very important. I want to realize crediting points for viewing ads, but don’t know how to do it. Of course, I can send a request to the server when an advertisement has been viewed,
#Override
public void onAdOpened() {
if (sampleInterstitial != null) {
//something code
}
}
but I'm afraid that a person rummaging in the code of my application will easily find which request I am sending and will be able to easily emulate my requests for building up points. How can I avoid this? For example, is it possible to somehow check from the server whether an ad was viewed? Thanks for answers)
First of all the client cannot check the server side code , you do something like getting the ip address , time .. etc of anyone who views the ad , and inject it in a database or a file , and in this way you can know how many people did and give it credits
Your Php Ad page :
$ip = $_SERVER['REMOTE_ADDR']; // gets ip address
$time = date_default_timezone_get(); // gets time
// insert it in your file or database
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have reverse engineered an app (Settings.apk)
all i want to do is,
I want to make a SwitchPreference, on my case that i wanted to create a switch selector that will turn off / turn on double tap to wake for my device (i added it because that feature was absent, but anyway my device supports the feature)
here is my xml, i created the SwitchPreference on the accesibilty section of Settings app
here
I also created a ListPreference in the xml, i want to create a list selector that was in purpose of choosing the CPU freq & I/O Scheduler. I have also done doing it but it doesn't work as it intended to be.
the ListPreference's xml code is also on accesibility xml . What should i add to make both of them functional?
notice me if my question was offtop,
thank you.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need to create a system that checks a file for the username and password and if it is correct, it says whether or not in a label. So far I have been able to simply make one username and password equal to the variable, but need to link it to a file somehow..
String user_pass;
String user_name;
user_name= txtUser.getText().tostring();
user_pass= txtPass.getText().tostring();
if( user_name.equals("mube123") && user_pass.equals("mubarik") ){
lblDisplay.setText("Credentials Accepted.");
}
else{
lblDisplay.setText("Please try again.");
}
Your question is a bit ambiguous and I think you need to clarify some things like:
how do clients access the file in the first place? Through a local tool / through the web browser / ... ?
where is the list of valid credentials supposed to be stored? In an identity store such as "LDAP" or "ActiveDirectory" / hardcoded in your program / in a local file?
Depending on what your answers to these questions is, the solutions you want to look at vary quite a lot. For example:
when you have a user with access to the protected file itself and
want him to prevent reading the content without the right
username+password, you need to encrypt the file.
when you have a user that wants to download the file from a webserver, you can use the existing protection mechanisms of your
webserver (e.g. ".htaccess" file protection)
Without known what your are trying to achieve, it is not possible to answer the question ;)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Am not sure if the title describes what I want. Am developing an App on Android where kids start a new empty drawing project and finish with a full drawing at the end by dragging different shapes from a list of shapes that I created for the App. My problem is that I dont know how am going to follow the kid steps.
The kid is supposed to read a message in each step and try to apply it and then click on a next button to view the next step.
I want to make sure that he do exactly what the message is saying in order to view the next step.
Theoretically, how is this applied in Java ? If for example, there would be 20 steps how can I make the app follow up with him and make sure he is doing the right thing
You are looking to create a wizard. In Java use a MVC libray Spring-MVC or if its android you can use similar approach. Basically you want steps and views while saving the state - typical MVC pattern. Have a model object that is passed along to the views. Each view will have portions of the model that it can read/write to.
Android -refer to WizarDroid.
Spring - AbstractWizardFormController will help
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm making a webpage and in it the values inside the combo box depends upon the selection of some other field like for registration form by selecting a specific country, the combo box for the states displays the states of only that country. So does this dynamic allocation of values to the combo box occurs with javascript or with some back-end programming language like java or C++? If it can occur through both than which would be more advisable to use?
Thanks in advance.
You can technically set the values of the select's options (I am assuming that is what you mean by a combo box) by doing multiple roundtrips to the backend, remembering all submitted values and then rendering HTML which has the correct options selected back to the user.
However, that is what used to happen 10 years ago.
Now, using Javascript for this task is a nobrainer. There are two ways of doing this using Javascript too, depending on how complex the logic for deciding what options to populate the select boxes is. If it requires several DB queries, then it is best to perform an ajax call to the backend request for the options while temporarily suspending the UI and showing a loading screen.
If the decision is simple, then you should do it on the client, using only Javascript and without performing calls to the backend. This last options is the preferred one since it keeps the UI responsive and does not cause any extra load on the backend.