EJB / EE :: Component Distribution - Always Treat It As Last Resort?
Feb 12, 2015
I heard one of the senior architects in my company before tell me to treat component distribution as a last resort. So if EJB were created for such, why were they created if component distribution is not encouraged anyway? just got confused here. I remembered this because I am currently in a dilemma of whether to redesign an app having performance problems. Options are either create EJBs for it and put them in another server or purchase another server to have a load balanced setup.
View Replies
ADVERTISEMENT
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
Apr 4, 2014
Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values . The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered.
No input prompt
Terminate input by typing CTRL/Z (two keys typed at the same time) on a separate input line (use CTRL/D on Linux/UNIX systems)
Use hasNextInt() to terminate your input
Format as below (slightly different from the text example)
Z:dbraffittWeek10> javac Histogram.java
Z:dbraffittWeek10> java Histogram
10 10 10 10 10 20 20 20 20 20 20
20 25 35 45 55 65 75 85 95
ctrl/z
1 - 10 | *****
11 - 20 | *******
21 - 30 | *
31 - 40 | *
41 - 50 | *
51 - 60 | *
61 - 70 | *
71 - 80 | *
81 - 90 | *
91 - 100 | *
What I can not figure out is how to use hasNextInt() to terminate the loop. How to not have an input prompt. How to use ctrl z to terminate the input. Or to make it where it doesn't involve range values like -1.
Java Code:
import java.util.Scanner;
public class Histogram
{
public static void main (String[] args)
{
Scanner scan = new Scanner (System.in);
int [] nums = new int[101];
[Code] ....
View Replies
View Related
Apr 4, 2014
Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values . The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered.
No input prompt
Terminate input by typing CTRL/Z (two keys typed at the same time) on a separate input line (use CTRL/D on Linux/UNIX systems)
Use hasNextInt() to terminate your input
Format as below (slightly different from the text example)
Z:dbraffittWeek10> javac Histogram.java
Z:dbraffittWeek10> java Histogram
[Code] ....
What I can not figure out is how to use hasNextInt() to terminate the loop. How to not have an input prompt. How to use ctrl z to terminate the input. Or to make it where it doesn't involve range values like -1.
import java.util.Scanner;
public class Histogram {
public static void main (String[] args) {
Scanner scan = new Scanner (System.in);
int [] nums = new int[101];
[Code] .....
View Replies
View Related
Apr 12, 2014
I cannot add the component from this class:
Java Code:
package TestVersion;
import java.awt.Color;
import java.awt.Graphics;
public class matWood {
private int woodX = 250;
private int woodY = 100;
[Code] ....
The error is at Java Code:
frame.add(matWood); mh_sh_highlight_all('java');
And this is what it says:
The method add(Component) in the type Container is not applicable for the arguments (matWood)
View Replies
View Related
Feb 23, 2014
I want to focus at a JTextField, how to do that? Can setfocusable work?
View Replies
View Related
Apr 13, 2014
I can't seem to add second component to frame what this class creates:
package TestVersion;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JFrame;
import TestVersion.CKeyListener;
import TestVersion.GameWorld;
import TestVersion.MatWood;
public class MYCoreWorld {
[Code] .....
View Replies
View Related
Nov 16, 2014
I've been looking through the Java API for a component similar to the direction selector compass in google earth (the one that acts like a circular scroll bar) to no avail. Any existing component before breaking down to creating the component myself.
View Replies
View Related
Oct 15, 2014
How can ı sum up component of an array?
View Replies
View Related
Jul 29, 2014
In a java application project called mycomposites, i created xhtml with a composite component interface and implementation in mycomposites/ src/ main/resources/testcomponents/myComponent.xhtml...Then I created a new project testmycomposites added mycomposites as dependency. Here is the source of an xhtml that should use myComponent:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
[code]...
However running project, I get error:<tp:myComponent> Tag Library supports namespace: http://java.sun.com/jsf/composite/testcomponents, but no tag was defined for name: myComponent
If i put the same custom component in resources/testcomponents folder of the same project everything works fine.I can't find any example in wich custom composite components are located in a dependency.
View Replies
View Related
Feb 1, 2014
I have created a text file that contains a small list of toy names and prices, like:
Barbie, 12.95
Lego, 15.99
Hot Wheels, 5.00
Power Rangers, 6.49
And what I would like is my application to read the contents of the file and store the toy names in a list component. And then I want to be able to select a toy name from the list and add it to a shopping cart that is a list component as well. I want to the application to have menu items and buttons to allow me to remove items from the shopping cart, clear the shopping cart of all selections, and check out.
When I check out, the application should calculate and display the subtotal of all the toy names in the shopping cart, the sales tax (which can just be 8 percent of the subtotal), and the total.
How to create this simple application example I've just made up, and I'm going to add and use this example to create a bigger application myself.
View Replies
View Related
Nov 4, 2014
I am developing an application where blind person can interact with computer i have completed the part where computer responds as per command given by user.The part where i am stuck is i want to give voice feedback as user moves the curser for example if mouse is on d drive then user should get feedback that its d drive....i want to do it for whole windows ...
View Replies
View Related
May 9, 2014
I have an issue about loading images from css using a composite component. The folder structure is:
resources
resources -> css -> componentname
resources -> images - > componentname
resources -> WEB-INF
If i write in the css something like
border-image: url(resources/images/componentname/image.png) !important;
or
border-image: url(images/componentname/image.png) !important;
i have a 404 error and i can't see the image.
I able to load the image only if i write path with context-root:
border-image: url(/<CONTEXTROOT>/resources/images/componentname/image.png) !important;
but i can't write explicit context root in css files!!
So, i tried to use resource EL variable:
border-image: url(#{resource[image/componentname/image.png]}) !important;
but this last way render
border-image: url("/<CONTEXTROOT>/javax.faces.resource/images/componentname/image.png.faces.faces") !important;
and i not able to replicate the right way written above.
The project is developed with RSA9 and WebSphere Portal 8, but if i try to execute it in NetBeans (no portal) it run correctly!
View Replies
View Related
Apr 16, 2014
I have to create a new custom tag "imageLabeable" as a div contains a GraphicImage and an OutputLabel (primefaces).
Since I want to make it reusable as much as possible, I tried to write, in cc:interface section, all GraphicImage attributes (id, value, binding etc) and some new (GraphicImage is the main component among the two). But after that I have must associate GraphicImage attributes with the attributes created in cc:interface:
<cc:interface componentType="imageLabeable">
<cc:attribute name="value" />
<cc:attribute name="alt" />
<cc:attribute name="width" />
<cc:attribute name="height" />
[Code] .....
As you can see, if I have a lot of attributes I have to write a lot of association. Furthermore, if I see html rendered code with Firebug or similar, I see all of these associations.
Can I inherit these attributes automatically? Or associate it in easier way?
View Replies
View Related
Mar 7, 2014
<tr:selectOneChoice value="#{bean.aValue}" required="true">
<f:selectItem itemLabel="Option1" itemValue="1"/>
<f:selectItem itemLabel="Option1" itemValue="2"/>
<f:selectItem itemLabel="Option1" itemValue="3"/>
</tr:selectOneChoice>
Supposed that selectItem loads a list from the database.
But I want to display "Option1 - testing" without modifying database value.
testing is a string datatype in the backing bean
View Replies
View Related
Jan 31, 2014
I have created a text file that contains a small list of toy names and prices, like:
Barbie, 12.95
Lego, 15.99
Hot Wheels, 5.00
Power Rangers, 6.49
And what I would like is my application to read the contents of the file and store the toy names in a list component. And then I want to be able to select a toy name from the list and add it to a shopping cart that is a list component as well. I want to the application to have menu items and buttons to allow me to remove items from the shopping cart, clear the shopping cart of all selections, and check out.
When I check out, the application should calculate and display the subtotal of all the toy names in the shopping cart, the sales tax (which can just be 8 percent of the subtotal), and the total. create this simple application example I've just made up, and I'm going to add and use this example to create a bigger application myself.
View Replies
View Related
Oct 28, 2014
I am using the Javafx 8 Date Picker. Its works fine. I have defined a stylesheet for my application and in that style sheet i have a style for Button. I apply this style to the every scene. Now my question is: When I use the datepicker and I click on the calendar icon, the datepicker popup appears and the left and right arrows adjacent to month and year fields in the seems to pick the style of the button class from style sheet defined in my application., Is there a way to avert this and tell datepicker to use default styles and not the styles defined my application.
I tried removing the style at runtime from the scene, but of no use.
View Replies
View Related
Mar 7, 2014
Can I add actionListener to a button component without creating a reference to it? Look at my code below:
public void init() {
setBackground(Color.red);
//Create the layout
setLayout(new BorderLayout(20, 5));
//Add buttons
add("North", new Button("Red"));
add("South", new Button("Yellow"));
add("East", new Button("Cyan"));
add("West", new Button("Magenta"));
add("Center", new Button("White"));
}
Or should I just do the usual instance.addActionListener(this) like myButton.addActionListener(this)?
View Replies
View Related
Aug 21, 2014
I am trying to use the JList to display a list of students. Now, each student has a first name, last name and course taken. each courses taken by the student has its' own name, level and idNumber. For now, I am just trying to create my own custom JList model for the students. I have the custom model as well as the button event calling it. Unfortunately, when I click the button to display the student info added, the component is NOT fired up!..
I am not sure what I have done wrong regarding creating the component because I can display the information on the console and the list contains everything I have added but just to display it on the component is NOT working. I have broken the codes into sub classes, you can add the classes to the same package or create sub packages to insert individual classes.
The student class
public class Student {
private String studentName;
private String studentID ;
public String getStudentName(){
return studentName;
[Code] ....
View Replies
View Related
Feb 1, 2014
I am learning Java on my own and I am taking on very small project by myself for fun, and I'm just stuck on this small part of the project.
So I have created a text file that contains a small list of toy names and prices, like:
Barbie, 12.95
Lego, 15.99
Hot Wheels, 5.00
Power Rangers, 6.49
And what I would like is my application to read the contents of the file and store the toy names in a list component. And then I want to be able to select a toy name from the list and add it to a shopping cart that is a list component as well. I want to the application to have menu items and buttons to allow me to remove items from the shopping cart, clear the shopping cart of all selections, and check out. When I check out, the application should calculate and display the subtotal of all the toy names in the shopping cart, the sales tax (which can just be 8 percent of the subtotal), and the total.
View Replies
View Related
Jun 20, 2014
I have a problem to display a popup with the information of the registered event. I would like the user to hover over a particular event exhibited only the description of the event without having to click on the event to view information. I would like to make an ajax request to that was displayed a popup.
But do not know how to implement jquery and javascript. Well, I am new to programming. My code that generates the schedule is as follows:
<p: schedule value = "#{bean.datamodel}" widgetVar = "sheldule" locale = "en"
rightHeaderTemplate = "prev, next" leftHeaderTemplate = "today" centerTemplate = "month"
id = "events"
tooltip = "true">
<p:ajax event="dateSelect" listener="#{bean.onDateSelect}" update="eventsNew" oncomplete="eventDialog.show();"/>
<p:ajax event="eventSelect" listener="#{bean.onEventSelect}" update="eventsNew" oncomplete="eventDialog.show()"/>
</ p: schedule>
In my Bean have methods that make the selection of date and event. Have I configured the option of setEditable to true. Ajax function, jquery or javascript to show the popup containing only observation and event date. And looked at the documentation of primefaces and not found any implementation to solve my problem.
View Replies
View Related
Apr 28, 2014
I don't know if this is possible before JSF2.0, but I got a requirement that basically says that I need to be able to add focus to a certain element on the page using a custom JSF 1.2 component.
Currently, I do this with a short jQuery method where you add a class called 'focus' to the inputText component you want focus on. This works perfectly, but I need to also foresee a nested component inside h:inputText to do this.
Example:
<h:inputText id="myFirstTextField" value="#{bean.someText}">
<o:focus/>
</h:inputText>
I had thought about just putting an element with a certain class and using a jQuery selector to get its parent, but then I realized the html input tag does not allow subtags and that couldn't work, so I need something that won't be rendered but will do the job.
Migrating is evidently not an option.
I'm using Seam 2.1.2 and richfaces 3.3.4
View Replies
View Related
Nov 14, 2014
I have a big issue to render this html page with the webview component :
<html><head lang="en"> <meta charset="UTF-8"> <title>Pb Rotate</title> <style type="text/css"> #myDivRotate {
color: purple; background-color: #d8da3d; height: 200px; width: 300px; margin-top: 20px; margin-left:20px; -webkit-transform:perspective(400px) rotateX(30deg); -webkit-backface-visibility: visible; }
</style></head><body> <div id="myDivRotate"> Coucou
</div></body></html>
The problem is from "perspective" in -webkit-transform. Without it's ok. But with this one, the result is different from a standard browser like chrome or safari.
View Replies
View Related
Aug 4, 2014
I wish to use args passed to main(String[]) during application execution to a Swing component.
In a simple example, assume args passed are: a b c d
And here is the result I look for:
package argsinswing;
import javax.swing.JOptionPane;
public class ArgsInSwing {
public static void main(String[] args) {
String str1 = args[0];
[Code] ....
View Replies
View Related
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
May 28, 2014
For example, say I have I BoxLayout with a few JButtons in it. How could I make it such that I could drag a JButton such that it could be in front or behind the others?
I've thought about using ComponentMover and just switching to a null layout right before moving it and switch it back right after like bellow, but I'm not sure how to make it keep the change in order.
import java.awt.LayoutManager;
import java.awt.event.MouseEvent;
public class LayoutComponentMover extends ComponentMover
{
private LayoutManager layout;
[code]....
View Replies
View Related