When we have a jsf form to store clients in a ddbb for example and the backing bean is in session scope.... Lets think of a user that requests 3 times the xhtml view with the form to store 3 clients.
1) If we dont reset the backing bean each time the form is processed, he would see the values he sent beforea and it doesnt have much sense, right?
2) Here there is an example of clearing form after submitting : [URL] ...... Clearing the form after submititng is a common practice for the reason of the statement 1, right?
3 ) What is the best or normal approach to reset values in a form? when the user requests it or done automatically by the application after processing a form?
4) Are there known issues about resetting or not resetting the values in a form bean?
I tried this program, its guessing game. Where program decide 1 number and user will guess number. I am getting 1 problem. When user want to play game again.the random number remain same. So where i can put reset random in code..? And 1 more question if I want to write driver code for this. What should i transfer to driver code.
import java.util.Random; import java.util.Scanner; public class GuessGame { public static void main(String args[]) { String choice="y";
I want to have a button in my Jsp's labeled "next" that takes me to the next JSP in a certain order. Imagine a book: every time you click next you go to the next page.
Each page is a JSP that is named "page#" where # stands for the number (page1, page2,etc).
I was structuring my app this way: one controller,one controllerhelper,multiple JSPs.
The "next" button in the JSP's would always have the same name as not to overcode in my controllerhelper with too many options for the button that was pressed.
So my idea was to retrieve the name of the current JSP and work the string in order to add a number (page4 turns into page5) and forward it through a requestdispatcher.
That is the problem as I am not able to get the name of the current JSP since the url changes after the first page to the servlet url.
import java.util.Scanner; public class Exercise1{ public static void main(String[] args) { String employeeName, employeeNumber, position, department ; double otpay, salary, deduction, hrs, rate ; Scanner input = new Scanner (System.in);
[Code] ....
That's my codes but its wrong according to our prof. it should be in frame form. i don't know how to do it since i did not encountered framing since i was started in java.
I have a form containing several fields, 2 of which persist to different table in a database than the rest of the fields on the form. I have no problem persisting the data into both tables of the database, and after the form is submitted I reset the form to its default values. That all works fine.
But in the same session, when I open another form (a search form) and enter search criteria, which then displays a datatable containing the search results, those 2 values that are persisted to another table are not showing up, but the rest of the data is.
Here is the method that calls the persist methods:
@ManagedBean(name = "foreignPartyController") @SessionScoped public class ForeignPartyController implements Serializable { ... public void saveData() {
[Code].....
The values do show up, but the problem is, when a subsequent form is opened in the same session (e.g. a search form) the field for that value shows the actual value, instead of the field being blank.'
I am not sure why the data from the one database ("parent") is showing up, yet the data from the other database ("child") is not.
Is it something I am doing wrong? I thought by setting the setter in the child controller class back to a new instance of the Entity class (PolicyPayment) that it would reset the form to default values, but at the same time retain (or save) the inputted values in the same session.
I have a button on UI which adds messages and when the user clicks on it the form gets submitted, meanwhile the user is clicking on refresh(F5) multiple times which is causing the same message to be displayed multiple times. To resolve this , I am converting the form from a synchronous submit to Asychronous but it is still not working. Below is the code:
I got the below exception .how to resolve this .It's receiving the data up to 10 min then suddenly below error happening. I have embedded the source code below
java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at sun.nio.cs.StreamDecoder.readBytes(Unknown Source) at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
I have to write a program that will generate 20 random circles with random radius lengths. If any of these circles intersect with another, the circle must be blue, and if it does not intersect, the color is red. I must also place a button on the JFrame. If this button is pressed, it needs to clear out the JFrame, and generate a new set of 20 circles following the same color rules. I am extremely new to Java Swing and am really stuck. I have everything working except the button. I cannot get a new set of circles to generate.
I have 5 radio buttons in my gui, I have a reset button which I have resetting everything else but now I am looking to remove the dot from the selected RB when you press the reset.
The problem i believe is that I have the max value set to the first value given out, but every time the loop repeats the Max value gets reset to the next value in the file.
Essentially the program is supposed to read a list of credit card transactions and tell the user which transaction is the highest.
Here's the list of the sample file, note that the number of transactions could change that's why i haven't tried simply passing the values to method.
Bicycle 562.90 Groceries 138.43 Hotel 612.00
import java.io.File; import java.io.IOException; import java.util.Scanner; public class CreditCards { public static void main(String[] args) throws IOException { String fileName = "C:/Users/David/Desktop/CreditCard.txt"; File inputFile = new File(fileName);
I am a JSP/Servlet newbie currently adding the first servlets to a web site that had been static all along. My local instance worked great but the servlets did not respond on the test instance. Apparently, my hosting service provider requires me to use an invoker servlet mapping.
Adding this to local web.xml broke the application but the servlets respond on test instance (when their calls are not preceded by another servlet call). A Servlet fails when it is called immediately after another servlet has been called.
What I saw happening on test is URL for first call is of the form:
The servlets are invoked using "href=servlet/<servlet-name>?Id="
How can I avoid the inclusion of 'servlet' in the URL and reset the URL to the JSP page it navigates to after processing of the servlet?
P.S.: I am also trying to enable the Invoker servlet on local so I can troubleshoot easier. I went through the changes to Tomcat's web.xml and context.xml. However, my local servlets did not respond even after calling them using "href=<servlet-name>?Id=". Is there a way I can check if my invoker is active?
I'm back with a question about the Black Jack assignment. I've created a working game that works for one round, as well as a reset button that's able to clear the board of the old hand. However the runGame() loop, which checks whether a player has played his hand seems to freeze the program the second time around
private void initNewGame(){ dealer.addCard(); for(int i = 0; i < numberofplayers; i++){ players[i].addCard(); //draws card, adds score and paints card to the board players[i].setStatus(false); //makes the buttons usable in the players[] class
[Code] .....
I know it's probably not optimal having an while loop constantly running to check the status, but I can't seem to figure out why it freezes.
I don't understand why the object reference variable 'a' cannot be recast from a thisA object reference to a thisB object reference.Is it the case that once a reference variable is linked to a particular object type then it cannot switch object types later on.I am facing the Java Associate Developer exam soon and I am just clearing up some issues in my head around object reference variable assignment,
class thisA {} class thisB extends thisA { String testString = "test";} public class CastQuestion2 { public static void main(String[] args) { thisA a = new thisA(); thisB b = new thisB();
I am having a problem passing an int value from one class to the other. The gist of the objective of this program is to compute a local sum at each client, and then once the local sums are computed.. to compute the overall sum from all the clients. My problem is that I'm having trouble figuring out how to pass each sum from each individual client in the class multicastSenderReceiver to the readThread class. I keep getting an error.
I feel that I have to be able to pass the sum value from each client generated in multicastSenderReceiver to the other class, because that is the only way I'll accurately be able to sum up all the values..
I'm using Java in BlueJ where I'm trying to write a class to store cycling club membership details in a map. I'm trying to pass a map as a parameter to a function that will iterate over the map and print out the member details. My code is:
public class CtcMembers { //instance variables private Map<String, Set<String>> memberMap; /** * Constructor for objects of class CtcMembers
[Code] ....
When I execute the following in the OU workspace:
CtcMembers c = new CtcMembers(); c.addCyclists();
I can see a map populated with the expected details.
When I execute the following in the OU workspace:
c.printMap(c.getMap());
I get the following error:
java.lang.ClassCastException: java.util.HashSet cannot be cast to java.lang.String in CtcMembers.printMap(CtcMembers.java:81) in (OUWorkspace:1)
I wasn't aware I was trying to cast anything so this has got me baffled.
This is my first time working with C++ and I have put together this program and came up with two errors and I am unsure what it is wanting me to do. The errors I got are:
1>c:usersownerdocumentsvisual studio 2010projectsweek5week5passing_by_value.cpp(30): error C2064: term does not evaluate to a function taking 1 arguments 1>c:usersownerdocumentsvisual studio 2010projectsweek5week5passing_by_value.cpp(38): error C2064: term does not evaluate to a function taking 1 arguments
#include<iostream> using std::cin; using std::cout; using std::endl; //initialize arrays int incr10(int* numa,int* numb);
I'm trying to pass a parmeter to a jsf page from a servlet(i.e. associated with paypal adaptive api), but I keep getting the following error, even though the productType on ProductDetailsVO is a String.
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
must be a number consisting of one or more digits.), detail=(j_idt2: '45;productType=Sport' must be a number between -2147483648 and 2147483647 Example: 9346)]
Calling JSF page contains:-
returnURL = new URL(new URL(request.getRequestURL().toString()),"pages/paypalpaymentapproved.xhtml?paypalID="+paypalID+";productType=Sport"); response.sendRedirect(returnURL.toString());
I enter a value in the text box in one class and want to pass that value to another class in order to compare it and color the cell in a table. In the first class I have
I have a java application in which when starting it a map is opened and a screen is captured. The capturing is in certain time interval. I want to enable the user to change the interval for the automatic capturing the map. I placed a text box in a JPanel. I want to pass the value which was entered in it to the html page which opens a Google map. Since I am new in java programming, I found that I can do it by using applets. I made an applet, and tried to call it in the html file. But now instead of opening the map file in a browser, it opens very quickly only black window.
Here is my applet:
package cege.ui; import java.applet.Applet; import java.io.IOException; import cege.ui.GuiMain; public class AppletTInterval extends Applet { private int TimeInterval=0;
[Code] .....
And the code in the html file where I try to call the applet, i.e. to pass the value which is returned by the applet is:
<script src= <!--"https://www.java.com/js/deployJava.js"></script> <script> var attributes = { id:'AppletTInterval', code:'cege.ui.AppletTInterval', width:1, height:1} ; var parameters = { jnlp_href: 'AppletTInterval.jnlp'} ;
[Code] .....
Can I use this way to pass a value from the java class file (from the JTextField into the html file?