JSF :: Application Scoped Data Updating
Feb 18, 2015
I have an application scoped and i want to edit it from request scoped data. I use this code but application scoped data are not updating. What i am doing wrong?
Application Scoped Data
@ManagedBean
@ApplicationScoped
public class ApplicationData {
protected String contactEmail;
public String getContactEmail() {
return contactEmail;
[Code] ....
View Replies
ADVERTISEMENT
Mar 29, 2015
I am coming from a Seam 2 and ATG background, and working on re-writing an old Seam 2 application using JSF 2 on Tomcat 8. I've run into a snag:
I have an application scoped managed bean, let's call it EMail. It holds a collection of Email objects, and does some other stuff.
I have an IMAPClient, which is currently setup as an application scoped managed bean (mostly to simply configuration, etc...).
I need to call a method on the IMAPClient to go check email every X seconds (let's call it 60 seconds), and add any new email into the Email managed bean's collection of email. In Seam 2 this was easy with the @Asynchronous annotation. In JSF 2 I can't figure out how to do it. I've tried using Quartz, which will happily run my IMAPCheckJob every 60 seconds, but I am so far unable to figure out how the IMAPCheckJob can get access to either the IMAPClient or the EMail beans.. There's no dependency injection into the Quartz Job, and since it's not executing in a HTTP request flow, there's no Faces context available.
It seems like there has to be some way to allow for scheduling and still have access to the benefits of the Application scoped managed bean DI system...
Or do I need to give up and move to JBoss with EJBs and CDI instead of JSF beans?
View Replies
View Related
May 24, 2014
If I have the next request scoped JSF bean for example:
public class UserBean {
private String name;
private String surname;
public String saveUser(){
//service is called to save a user
}
public String updateUser(){
//service is called to update a user
[Code] ....
1.In struts for example the Action classes are singletons and I think is the way it has to be because they contain business logic and is the same logic for every user but in JSF because of you mix properties from a form and methods with business logic, these beans have to be request scoped like the above one but is very wierd that a bean which contains business logic(saveUser()....) be request scoped;I dont see it effective, is like creating a new servlet each time you want to save a user but I think is the way JSF works, right?
2 To avoid the mixing of form properties in a bean with business logic, some people say to have the form beans request scoped and actions beans session scoped.
- Is this right?
- How then can you get the request form bean in the action bean?
- The scopes in JSF are request, session and view so you cannot create singleton action beans, the best you can get is a session action bean, right?. Once again I dont see the point of creating action beans with session scoped,they should be application scoped if it existed
View Replies
View Related
Aug 4, 2014
What would be the most effective method to display data grabbed from a web source that is queried every second, for example the most recent EUR/USD price?
I already have access to the data stream, and I've built a simple FXML in javaFX that contains a grid; I'm not sure how to approach putting the live ticking data into the grid so it continues to update as the price changes, for example.
View Replies
View Related
Aug 28, 2014
I have a tree-based data structure that looks somewhat like this:image1.png..Every tree always has a height of no more then 3, and each of these classes has a very specific use, generalization is not possible between them.Now, I want to display my data structure with a JTree in a Swing application. A JTree needs a TreeModel and so I created a custom TreeModel for my classes, it looks like this:
public class CustomTreeModel implements TreeModel {
private Root root;
public Object getRoot() {
return root;
[code]....
But then I would introduce this interface to my Model classes just for the purpose of writing the View. So my data model has to be altered to make the View work, this sounds completely against MVC to me and also like something I dont really like.On the other hand, the CustomTreeModel would be much simpler, easier to understand, easier to maintain and just in general more pleasing to the eye.Should I change my Model to improve the View? Is instanceof okay to be used in View classes?
View Replies
View Related
Jan 1, 2015
I am trying to develop a new web application which takes in data from a form and stores data in a database.I have included all the three files join.jsp(the form which takes in data),reg.java(servlet) and JavaConncetDb(method which connects db and servlet). I get a 404 error when i try load the web application.
My file structure in eclipse
The error I am getting
join.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
[Code] .....
View Replies
View Related
Mar 2, 2014
I'm using netbeans to develop an application to send and receive data via RS 232 standard. I can send data but I can't read it.what can I do? I have this message in the console: Underlying input stream returned zero bytes. (I must use also threads to have application in real time but I don't understand very well....
View Replies
View Related
Oct 27, 2014
I want to create an application wich can handle xml files ( display xml files's data on a html page) + insert those data into an oracle database.
I'm new to that, it a project for my internship. wich API is the most appropriate for that ( Jdom or Xstream or other), wich framework i can use ( there is only 3 IHM : connexion, upload file, display data, confirmation insertion data)?
View Replies
View Related
Apr 29, 2014
I am using JSF2 with Primefaces. Here is my business requirement-Hidden field on JSF page should take the value from the session object that is set in managed bean. Session object is updated every time when the user submits the page. I am able to update the session object in the managed bean and able to get the value in the hidden field first time and after that i see the same value in the hidden field even though session object has different value. Here is the hidden field: <h:inputHidden id="xyz" value="xyz"/> i tried using sessionScope but still didn't work.
View Replies
View Related
Feb 20, 2015
I have a jTextPane set up and a panel with radioButtons. My jTextPane displays the contents of a text file I have chosen. The 3rd line, 4th index, displayed in my jTextPane specifies a value of type int. When I click my radioButton, I would like that value to increase by 1. So far, I have the following code. I tried to pane.setText(value + 1), but that doesn't seem to work. How do I update the value and display the updated value in jTextPane?
My code :
private final ActionListener actionListen = new ActionListener() {
for(String line: pane.getText().split("")){ String lineThree = line[3];
int value = lineThree.charAt(4); if(radioButton.isSelected()){
pane.setText(value+1); } }};
View Replies
View Related
Mar 20, 2015
The program runs well , it adds the applet but it dosn't update the interface unless I press "_"(Minimize) . To be more clear , the object paints a spring wich goes through 4 stages , it is added to the JFrame but it dosn't uptade until I minimize the frame , that is when it goes to the next stage .
The main class which calls the spring to be added to the frame :
public class principal implements ActionListener ,Runnable{
JTextField field;
JFrame frame;
private class Action implements ActionListener {
public void actionPerformed(ActionEvent event) {
frame.repaint();
[Code] .....
View Replies
View Related
Oct 18, 2014
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
[Code]....
I am trying to Make A GUI which has a Jcombo box i also want it to have a jlabel that up dates depending on which option the user selects from the JcomboBox
for exampl if i select lion i want it to say you chose lion on the Jlabel and if i choose ostrich i want it to say ostrich and so on
View Replies
View Related
Sep 26, 2014
I have two images. I want to be able to click them and kick off a call to a listener in Java to change a value in the bean. I also want the view to update my dropdown (labeled "menuModel") to either be rendered or not, depending on which image I click. Alternatively, I would be fine with the dropdown simply being disabled and enabled for the same criteria.
So far, the listener kicks off fine, and the value gets updated correctly in the bean. However, the view never gets updated. I have tried this a hundred different ways, but nothing seems to work. If I hit refresh on my browser, the view updates. But I want it to do it automatically.
I am using standard JSF 2.1.
<div style="font-family: Verdana; font-size: 10pt; color: #FFFFFF">
<h2>Calibrations</h2>
<h:form id="tunerSelectionForm" style="color: #000000">
<h:commandLink>
[Code] .....
View Replies
View Related
Jun 15, 2014
I have loaded the combo box at starting of program.When i am adding the element to combo box through database it's not updating visually.But the inserted data is successfully loaded in List.
void update_Attan() {
DefaultComboBoxModel nm = new DefaultComboBoxModel(new StudentMethods().update_combo_AttendanceType());
cmbStdAttType.setModel(nm);
}
View Replies
View Related
Sep 25, 2014
When I add an element to my array, I have to make sure that it stays a heap, ie every child is smaller than its parent. However the method that I am using for this, trickling up, is not updating the elements properly, it pretty much just leaves is as is.
Here is the relevant code:
public class MaxIntHeap {
int[] array;
int actualSize = 0;
public MaxIntHeap(){
array = new int[20];
[code].....
View Replies
View Related
Aug 14, 2014
Why the Progress Bar is not Working in Second attempt?When i am Invoking Below Method on actionPerformed at first attempt its Working Fine but After that Its Not Working at all....
void initWait() {
go.setEnabled(false);
browse.setEnabled(false);
choice.setEnabled(false);
wait.setVisible(true);
wait.setMinimum(0);
wait.setMaximum(Info.getMp3().length);
System.out.println(Info.getMp3().length);
wait.setStringPainted(true);
[code]...
for a better Understand see this Mp3Arranger.jar or see the Whole Project SourceCode
View Replies
View Related
Oct 22, 2014
My program is working fine. When I executes it, it shows me this:
The clock is 54 minutes over 23 (+41 seconds.
and when i press ENTER, it shows me this:
23:54:41
But then it won't show me the update. I want to update the time, for example when I started the execution the time was 23:54:41 but it must show me something like 23:54:45, because I need the current time.
I have searched the whole internet about this but I don't know how to use the "Date.update ();".
Here is my code
package p2;
import java.util.Calendar;
import java.util.Date;
import javax.swing.JOptionPane;
public class Time {
public void myTime() {
Calendar cal = Calendar.getInstance();
[Code] ....
View Replies
View Related
May 6, 2015
Alright, I have a JavaFX gui that is creating a new instance of data calculation to graph in a chart; however, the data is not updating each time the Platform.runLater() feature executes. Each time an event occurs, a new instance with the same variable name occurs. I use to get methods to retrieve the data I want, so shouldn't the values update each time the new instance is created? This is a very condensed version of what happens with the event, but this is what is not working correctly.
Event:
solarPlot = new SolarTracker();
solarPlot.getElevation();
solarPlot.getAzimuth();
Class constructor :
public SolarTracker() {
[Code] .....
View Replies
View Related
Sep 4, 2014
If I run this code. I can manipulate it so that X wins. When the third X button is pressed, there is no display saying that X has won and that the game is over. I have read over this code for days and still have not figured it out.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TicTacToe extends JFrame implements ActionListener, WindowListener{
public JFrame window = new JFrame("window");
[Code] ....
View Replies
View Related
Aug 20, 2014
I am trying to create a tree that is like a take on 21 Questions. The tree pretty much just starts with three default values: the root/first question "Is it a mammal?", a left child "is it: human?", and a right child "is it: fish?", and then it builds off from there. It goes left for YES and right for NO. If the program guesses the wrong animal the user must enter the correct answer and a question that will distinguish the correct answer and the failed answer. That new question then becomes both the the failed answer and new answers's parent.
A little visual:
....................Is it a mammal?
...........It is: human?........Is it: fish?
*lets say it is a mammal but not human, ie a dog
Updated tree:
.....................Is it a mammal?
.....Does it have a tail?............Is it: fish?
Is it: dog?......Is it: human?
My problem is that after I update the tree 3rd time the values do not change properly. Lets say it is a mammal and its does have a tail, BUT its a cat, then, the updated question, which would now go before "is it: dog?" would be something like: "does it chase rodents?", which its left child would be cat and right would be dog.
However, when my program displays the values it would go something like this:
//first run: GOOD
Think of an animal and I will guess it!
Is it a mammal? Enter yes or no:
yes
Is it: human?
no
[Code] .....
So pretty much I can't understand what I'm doing wrong since the values in the print statements are right, but they are wrong during the actual run. Where is my error?
View Replies
View Related
May 4, 2014
Write a subclass of BasicGame in which the computer asks the user to choose a whole number from 1 to 100, inclusive. The program then makes a number of guesses. After each guess, the user tells whether the guess is too high, too low, or exactly right. Once the computer "knows" what the correct number is, the computer tells the user the correct number and the number of guesses tried. Have the program ask the user after each game whether she wants to play again. Design the program so that it always guesses the correct answer by the seventh try at latest. Hint: Have two instance variables that keep track of the smallest and largest values that the guess could be (initially 1 and 100). After each wrong guess, update these smallest and largest values appropriately.This is what I have written for the assignment:
Java Code:
import javax.swing.JOptionPane;
public class GuessThatNumber extends BasicGame
{
private java.util.Random randy;
private int itsCompNumber;
private int itsHigh = 99;
private int itsLow = 1;
[code]...
The part I'm having trouble with is changing the high and low values based on the input of "too high" or "too low," which I tried in the continueGame method... When I test the game, the values for itsCompNumber aren't restricted by the user's input at all, and I'm not sure how to fix it.
View Replies
View Related
Jan 21, 2015
I am working on a project in Eclipse, and it is my first time working with swing.I have the GUI setup the way that I like it, my hang-up is how to "update" the variables in the code as they are changed.The basics of the code is that I have several different String[] that will show up in a Jtable depending upon the input of the lists I have in the GUI.
in essence,
if list1==2 && list2==3
returnedarray = array1
I would like to have the returnedarray/Jtable be updated live as the lists are manipulated. So as soon as I change my list selections to...
list1==1 && list2==3
the code would shift to the proper array...
returnedarray = array2
If making the output update live isn't a possibility how would I code a button to update the input/output giving me the proper String[]?
View Replies
View Related
Feb 18, 2014
I create and populate someLinkedList with '*' characters as soon as a gameLinkedList object is created, so my class is something like
private int size;
public class gameLinkedList{
private CharNode game;
public gameLinkedList(String someWord){
size=someWord.length();
for(int i=0;i<size;i++){CharNode aNode = new CharNode('p');
[Code] .....
View Replies
View Related
Feb 21, 2014
I am trying to use a prepareStatement to update the database but I am getting an error on setInt - cannot find symbol and on the executeUpdate() I get error no suitable methods for executeUpdate (no arguments)
public Products UpdateProductsDB() {
pool = ConnectionPool.getInstance();
connection = pool.getConnection();
try {
stmt = connection.prepareStatement("UPDATE products SET qtyonhand=?, qtysold=? WHERE id=?");
} catch (SQLException ex) {
[Code] ....
I used similar code for an insert statement and I don't have these problems
View Replies
View Related
Mar 5, 2014
I have a TabView that generates the numbers of tabs, titles and content based off of the selected project from another field. I have managed to get it to load the proper number of tabs and content, but the first tab title displays the title of the first tab from the previous query.
The jsf is:
<h:panelGroup id="equipmentWrapper">
<p:tabView effect="blind">
<c:forEach items="#{databaseViewHandler.deviceTypes}" var="deviceType">
<p:tab title="#{deviceType.key}">
<ui:include src="#{deviceType.value}"/>
[Code] ....
And the method handling the content and number of tabs:
public DatabaseViewHandler() {
deviceTypes = new LinkedHashMap();
}
public Map<String, String> getDeviceTypes() {
return this.deviceTypes;
[Code] ....
The method findAssociatedEquipment() is called when it recieves a selected project to display.
The command button calls the update for panelGroup "equipmentWrapper". It updates fine for the ui:include and generates the correct number of tabs in the correct order.
So for example the first query might only generate one tab for an 881 device. Then if you select a project that should have a 2911 and 2960 it will correctly load both, but the title for the first tab will retain 881. Should you select a third it will have the title 2911 from the second project.
View Replies
View Related
Aug 14, 2014
The stacked bar chart not working with FXML and controller class. My code is given below
Controller class
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javafxapplication27;
import java.net.URL;
import java.util.Arrays;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
[Code]...
When I run this program, only the barchart populating, Stacked bar chart not displas any graph.
Output window
View Replies
View Related