JSF :: ValueChangeEvent NewValue Method Giving Wrong Value When Component Values Change Indirectly

Aug 1, 2014

My form looks like this:

<h:form>
<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
<p:outputLabel for="filetype" value="FileType: " />
<p:selectOneRadio valueChangeListener="#{selectView.changeServerAndSignmethod}" onchange="submit()" id="filetype" value="#{selectView.filetype}">
<f:selectItems value="#{selectView.filetypes}" itemLabel="#{filetype}" itemValue="#{filetype}" />
</p:selectOneRadio>
<p:outputLabel for="signmethod" value="Sign Method: " />
<p:selectOneMenu valueChangeListener="#{selectView.changeServers}" onchange="submit()" id="signmethod" value="#{selectView.signmethod}">
<f:selectItems value="#{selectView.signmethods}" itemLabel="#{signmethod}" itemValue="#{signmethod}" />

[code]....

As you can see there are two listener in my xhtml file one for filetype and other for signmethod. When filtype changes signmethod has to change which in turn changes servers. And if user changes signmethod using dropdown then also server should change. But my problem is when filetype changes, both the listeners are called, as signmethod also changea but the value in event object (e.getNewValue()) is not the new one but old one. Here is the SelectView Bean.This is the static initialisation part just for checking the output at the end of question.

static {
initFiletypes.add("Windows");
initFiletypes.add("Mobile");
initFiletypes.add("Mac");
initFiletypes.add("Solaris");
initFiletypes.add("Jar");

windowsSignmethods.add("Microsoft");
windowsSignmethods.add("Driver");
windowsSignmethods.add("Driver_Pagehash");
windowsSignmethods.add("HDR");
windowsSignmethods.add("Java2");
windowsSignmethods.add("Javame");
windowsSignmethods.add("MicrosftApps");

[code]....

I am changing servers in changeServerAndSignmethod by selecting first signmethod from signmethod arraylist which is giving correct result. But changeServers is also getting fired taking wrong event object's newValue method and changing servers to wrong values. When changeServers is fired bydirectly changing signmethod, by dropdown, it gives correct result. Is there a way I can stop changeServers to fire when the change came from changing filetypes rather than direct change by user on signmethod selectOneMenu.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: Change Location Of Component Using Grid Bag Layout

Jun 13, 2014

How to change the location of a grid bag positioned component after it's already been added to the layout earlier?

Example is if I want component 1 to change from row 1 to row 2.

View Replies View Related

Keep Getting Wrong Variable Values?

Oct 24, 2014

Whenever I run this I get:

There are not enough funds to do that

Balance: $0.0
Monthly Interest Rate: 0.375%
Account Start Date: Fri Oct 24 08:03:40 EDT 2014

I assumed that this is because the constructor Account(); is setting the variables to 0 every time the program runs even though I'm passing other variables through to methods and constructors. I've looked up similar programs and this is how it's done though. The steps to my homework say to create a no-arg constructor Account() that creates a default(0) account Id and balance. What did I do wrong?

import java.util.Date;
public class Account {
 private int Id;
private double balance;
private double annualInterestRate;
private Date dateCreated = new Date();
 public static void main (String [] args){
//Objects of Account to get non-static methods

[code]....

View Replies View Related

Getting Wrong Values When Calculating Perimeter And Area?

Mar 22, 2015

I've been given a school assignment that reads, "Rewrite the main class Geometry so it takes in the dimensions for the triangle and ellipse as user inputs and create a Triangle and an Ellipse class. Use the appropriate variable types, constants, variable names and computational formulas.

Triangle class will have a computePerimeter and a computeArea methods Ellipse class will have a computeArea method Create Report class

• Create a method createReport that takes the values returned from Triangle and Ellipse and combines them in the following message and displays it. Format the values so that they have 2 decimals.

“The triangle has a perimeter of [perimeter] with an area of [area] while the ellipse has an area of [area]”

• Create a method switchReport that takes the original string from createReport and changes the message to display using the available methods in the String class

“The ellipse has an area of [area] while the triangle has an area of [area] with a perimeter of [perimeter]”"

I've run into a problem when creating the createReport method. Everytime i run it i get incorrect values for the perimeter and area (namely i get zero every time).

my code is as follows:

public class Triangle
{
public double base;
public double height;
public double hypotenuse;
private double tArea;
private double perimeter;
  public Triangle()
{
base = 0;
height = 0;
hypotenuse = 0;

[code]....

For the triangle class and

public class Report {
  Triangle tri2 = new Triangle();
Ellipse eli2 = new Ellipse();
  public Report() { 

public void createReport() {
System.out.println("The triangle has a perimeter of "+tri2.computePerimeter() +" with an area of " +tri2.computeTArea() +" while the ellipse has an area of " +eli2.computeEArea() );
}

for the report class.the Geometry class allows you to input values and if i skip the report and simply print the perimeter and area they are correct. However with the report class it simply gives me zeros.

View Replies View Related

Random Generator Method Is Not Giving Correct Average?

Aug 4, 2014

Create an array that will store 7 temperatures.

Populate the array with 7 random temperatures from 1 to 100 degrees. (hint use a for loop and a Random number Generator)After the temperatures are in the array, calculate the average of the temperatures in the array.

Print out the average.Print out each temperature in a statement comparing it to the average such as:

The average temperature is 48.94

Temperature 1 is 5.0 and is below average.

Temperature 2 is 67.8 and is above average.

import java.util.Random; 
public class ArrayOfTemperatures
{
public static void main(String[] args) {
// Declare an array
int[] randomtemps = new int[7];
temps[0] = 45;

[code]....

View Replies View Related

Apache POI Method Returning Wrong Value

May 20, 2014

I'm using apache POI to input data from a excel database. I have a method that is supposed to count the number of rows containing data so I can use that number to initialize an object array. It's returning one more than the actual number of rows and I can't figure out why.

public int getDataRange() throws IOException{
int rowCount = 0;
Iterator<Row> rows = sheet.rowIterator();
while(rows.hasNext()){
HSSFRow row = (HSSFRow) rows.next();
rowCount++;

[Code] .....

I get an array index out of bounds exception at the highlighted line.

View Replies View Related

Polymorphism / Dynamic Binding - Invoking Wrong Method

Jan 9, 2014

Why is the equals-method in the super-class invoked? Shouldn't the equals-method in the sub-class be invoked(at least in the first if-statement since b2 is a B(i know B is also an A))?Is the equals-method overridden? Or does B have its own equals-method?

class SomeClass{
public static void main(String[] args) {

B b1 = new B(123,1);
B b2 = new B(123,2);

[code]...

View Replies View Related

Java Class Date Method Showing Wrong Year

Dec 31, 2013

We use a Java program to read an XML file and put its content into a database. We also use Date() to get the current date and insert it into a field in database with content from XML file. Everything worked flawlessly until today, the last day of 2013. We are getting 2014 for the year instead of 2013!!! System date shows correct year, so this must not be an issue.

View Replies View Related

Swing/AWT/SWT :: Panel Doesn't Refresh When New Component Added If Smaller Than Largest Visible Component

Jan 26, 2014

I have a JPanel that's using a simple GridBagLayout.

JPanel panel = new JPanel();
GridBagLayout qPanelLayout = new GridBagLayout();
qPanelLayout.columnWidths = new int[] { 0 };
qPanelLayout.rowHeights = new int[] { 0 };
qPanelLayout.columnWeights = new double[] { Double.MIN_VALUE };
qPanelLayout.rowWeights = new double[] { 0.0 };
panel.setLayout(qPanelLayout);
componentCount = 0;

Based on user input I am adding sub-panels to the panel. These sub-panels may vary in height. They take up the full width of the Panel.

public void add(Component comp) {
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(2,2,2,2);
gbc.gridx = 0;
gbc.gridy = componentCount++;
panel.add(comp, gbc_questionPane1);
}

The odd behaviour I'm seeing is that if the height of the new sub-panel I'm adding is less than the height of the largest sub-panel currently displayed then the main panel does not repaint. If its height is equal or greater then the Panel does repaint, and any sub-panels that were added but not visible before are now painted. What have I missed?

View Replies View Related

How To Change Value Of Boolean Within A Method

Dec 1, 2014

I read in a book that when you change the value of a method parameter that's a boolean or other basic datatype within the method it only is changed within the method and remains the same outside. I want to know if there is some way for me to actually change it within the method. For example:

public class Change {
void convert(boolean x, boolean y, boolean z) { //i want to set x,y, and z to false in this
x = false;
y = false;
z = false;

[code]...

I want to put in part1, part2, and part3 when i call the method than i want them to be set to false within the method. The specific reason i asked this question was because im trying to code a battleship and i have a subroutine class with a method that when its called it checks if a ship has been sunk. If the there was a sink than the method will set a ton of boolean variables to false.

Just to clarify, I want something like this:

void convert(thing1,thing2,thing3,thing4) {
//some code here that sets thing1,thing2,thing3, and thing4 to false
}
// than in main:
boolean test1 = true;
boolean test2 = true;

[code]....

View Replies View Related

Servlets :: How To Change URL To JSP Name After Passing To DoPost Method

Aug 12, 2014

I have a log in page accessed by: localhost/Security/Login.jsp

When I click a log in button, doPost() method is executed from Login.java and displays the contents from main.jsp.

However,its url on my browser is localhost/Security/Login.

Generally, the pattern is the address of Login servlet.

So if I click a button from main.jsp, error occurs because it is trying to locate a servlet from /Security/[Servlet name].

What I want is to change the url as I go to main.jsp to localhost/Home/main.jsp.

Is this possible?

View Replies View Related

Getting Mouse Click Method To Change Previous Object Properties?

May 19, 2014

I am having trouble with a mouse click method. In short I have a hexagon grid, and every time I want to click on one particular hexagon I want the color of the hexagon to change to blue(by default the color is grey). This part works, but when I go to click on another hexagon I want the color of the previous hexagon to change back to grey while at the same time changing the color of the current hexagon clicked to blue. So in other words, I only want one hexagon blue at a time. How might I do this?

I have a hexagon class for one particular hexagon, and a hexmap class for multiple hexagons. I know I should probably be handling mouse clicks in the hexmap since it deals with the whole thing. But I cannot say something like hexagon.setColor within a mouselistener in that class(it gives me a lot of issues). Here is some of my code :

public class Hexagons()
public Hexagons(HexMap theMap, int mapRow, int mapCol, int width, int height) {
this.map = theMap;
this.row = mapRow;
this.col = mapCol;
this.width = width;
this.height = height;

[Code] ....

View Replies View Related

How To Change State Of Object - Main Method Exception Error

Jan 8, 2015

The error I get when I execute my java file.

Exception in thread "main" java.lang.NullPointerExceptionat DogTestDrive.main(DogTestDrive.java:19)

Here is the source

class Dog {
int size;
String name;
void bark () {
if (size < 60) {
System.out.println("Woof woof");

[code]....

Some background: I'm reading "Head first Java 2nd edition" and I'm going through the examples which is showing me how to change the state of an object. The original code looks like the code below, however the previous chapter went over creating array's of an object, so I created an array of the object "Dog" and wanted to re-write it this way. To my understanding, it should work but it's giving me that error when I execute it. The error itself isn't very clear, if I could get a line number pointed to, that would work.

class Dog {
int size;
String name;
void bark() {
if (size > 60) {
System.out.println(“Wooof! Wooof!”);
} else if (size > 14) {
System.out.println(“Ruff! Ruff!”);
} else {
System.out.println(“Yip! Yip!”);

[code]....

View Replies View Related

Swing/AWT/SWT :: Can't Change Visibility Of Two JPanels When Calling Method From Button Event In Another Class

Dec 30, 2014

I have two classes involved in this portion. CheckIn_Search

(class #1) is my main UI and I am collecting search information from the user in a jPanel form. When they click "Search" it passes the search criteria to a method that contacts a web service and gets the results. These results are passed to coSearchResults

(class #2) that opens a jFrame and jTable (in modal format, over the main window created by CheckIn_Search.

The user selects a row in the table and that selection data is passed back to coSearchResults to populate a new jPanel form. When the data is passed from coSearchResults, I want to close its window, hide the first jPanel in CheckIn_Search and make the second jPanel visible. To accomplish this, I created a method in CheckIn_Search that simply hides/shows the panels (it will do more later).

I instantiate and call the method in CoSearchResults as part of the button click event. The problem is, it doesn't work. The panels are unaffected and there are no errors. I've put in break-points and it goes into the method.. Here is the coSearch_Results code.

Here is am retrieving the jtable row id and using the first value in the row to get the data from the table model as there is more data than what is displayed in the table. I'm sending that whole row of data to the method that changes visibility.

private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
// TODO add your handling code here:
int rowNum = jTable1.getSelectedRow();
String coNum = jTable1.getValueAt(rowNum,0).toString();
String[] text;

[code]....

View Replies View Related

Method Values For Enum Types

Nov 21, 2014

What class does method Planet.values() in the code below belong to? I thought it belongs to java.lang.Enum but when I could not see it in Java API 7.

package enumeration;
public class EnumTest {
public static void main(String[] args) {
//Planet myPlanet = Planet.EARTH;
// Check arguments supplied
if (args.length != 1) {
System.err.println("Usage: java EnumTest <earth_weight>");
System.exit(-1);

[code]....

View Replies View Related

Why Java Is Giving Error For Symbol

Sep 28, 2014

I am having trouble figuring out why java is giving me an error for the symbols. I will post the errors below the code.

Java Code: import java.util.Scanner;
public class ShelbyHarms_3_02 {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);

[code]....

View Replies View Related

Output Giving Question Marks?

Feb 6, 2015

I am testing a code given by my lecturer and the output it gives me are all question marks? Heres the code:

package assignment;
import java.util.Random;
public class DeckOfCards { // begin DeckOfCards data type

// playing cards of deck of cards
private PlayingCard[] deck;

[code]....

View Replies View Related

Window Should Pop Up Giving Properties Of Javac

Feb 20, 2014

I have just tried to learn java this week [COLOR="#000000"]and I am being held back by this once installed java jdk I nav to the java file and the bin file and then the javac file to find that the below tab does not exist

A new window should pop up giving the properties of the javac, there should be an attribute called Location..I can see the location option in my documents but in no other folder

View Replies View Related

Infile Output - Only Giving One Name Two Times

May 7, 2014

I am having issues with the first part of my program. When I got to display what is in the textfile, it only gives me one name two times. I cannot figure out what to do with my outer loop in order for it to read and output the entire data file.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.util.Scanner;
import java.io.*;
import java.text.*;
import java.math.*;
import java.util.StringTokenizer;

[Code] ....

View Replies View Related

Java Program Using Apache POI Giving Exceptions

May 13, 2015

I am having some serious difficulty getting my project off the ground. I have the following code:

FileInputStream file = new FileInputStream(new File("src/retestchecker/test_sheet.xlsx"));
//Get the workbook instance for XLS file
XSSFWorkbook workbook = new XSSFWorkbook(file);
//Get first sheet from the workbook
XSSFSheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(0);
Cell x = row.getCell(3);
System.out.println(x);

Everything is properly imported, etc etc.. But I am getting this error and I am not sure what it means:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
at retestchecker.RetestChecker.main(RetestChecker.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)

[Code] .....

Java Result: 1

I am using Netbeans and the latest version of Apache POI that was released May 11, 2015.

The line 23 that the error refers to is this line:

XSSFWorkbook workbook = new XSSFWorkbook(file);

View Replies View Related

JavaFX 2.0 :: App Hangs Without Giving Any Error Information

May 6, 2015

I have an app that is randomly hanging it doesn't give any error information when it hangs.
 
Is there at way to see what's going on when it hangs? e.g. the methods that are being called, where is the program execution at..

View Replies View Related

Method That Returns Non-Numeric Values - Switch Statement

Feb 23, 2014

I am trying to write out a program that takes numerical input from the user and converts it to a date using the English month name. I am experimenting with the method of a "switch" statement without using the "break" clause. However, I seem to be missing something, as Eclipse is telling me I have a syntax error with my block. My curly braces seem properly placed. Also, I made sure to follow guidelines to make my code fit on the screen and remain easy to read.

import acm.program.*;
public class MethodsThatReturnNonNumericValues extends ConsoleProgram {
public void run() {
int month=readInt("Enter month number");
int day=readInt("Enter day");
int year=readInt("Enter year");

[Code] ....

View Replies View Related

Write A Method That Returns Unicode Values Of A String?

Oct 25, 2014

I must write a method that accepts a string and returns an int. The method should sum the unicode values of each character, so the string "ABC" should return 198. Also the only string class methods I'm aloud to use are length, charAt, and substring. I just don't know how the get the Unicode value.

View Replies View Related

Method Call That Takes Large Of Two Absolute Values

Oct 6, 2014

Write a method called largerAbsVal that takes two integers as parameters and returns the larger of the two absolute values. A call of largerAbsVal(11, 2) would return 11, and a call of largerAbsVal(4, -5) would return 5.

I have tried this code using methods in the Math Class but I am getting an error in Practice-it that says

Line 4
Your method's return type is void, which means that it does not return a value. But your code is trying to return a value. This is not allowed.

cannot return a value from method whose result type is void
return Math.max(Math.abs(Num1), Math.abs(Num2));

Here is my code. What I am doing wrong?

public static void largerAbsVal (int Num1, int Num2)

return Math.max(Math.abs(Num1), Math.abs(Num2));
}

View Replies View Related

Numbers Divisible By 6 - Code Is Giving Different Result Then Expected

Aug 22, 2014

I am having problems with writing a simple program to see if a number is divisible by 6.

public void run() {
println("This program will display all numbers divisible by");
println(" 6 between 1 and 100.");
int x =1;
boolean divide =(x%6==0);

[Code] ....

It is telling that every number is not divisable by 6?

View Replies View Related

Output Is Not Giving Proper Result - Semantic Error?

Oct 5, 2014

why the output is not giving the proper result? Is this a semantic error?

public class Programming1Practice {
/* testing out instantiation and object oriented programming */
public static class staticValues {

[Code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved