JSP :: Use Hashmap From The Model In Script On The Page?

Apr 11, 2015

I have some paired values stored as a hashmap in my model, for example sake, we'll say the 'key' is a Manager's ID and the 'value' is the name of their department, so 'betty123' could be a key to a value 'IT', and 'dave345' could be a key for the value 'Finance'. This hashmap is populated from a database. In my form, I have two "Select" dropdown fields, one for "Department" (with fields which match the values in the hashmap), and one for "Manager ID". I want to autopopulate the "Manager ID" field when the "Department" field is changed, based on the values in the Hashmap. I understand that I can't access dynamically elements of the hashmap in a script, so, for example, I can't do this:

var specificDepartment= $("#department");
var managerId = ${departmentHash[specificDepartment]};
$("#manager").val(managerId);

Because this code is dynamic based on the value of "department" at the time it's run, whereas the departmentHash object is generated when the page is loaded.

Is there some other way I can do this? Am I approaching it the wrong way? FWIW, I'm using Spring 4.1.1 and jQuery 1.8. I understand the conceptual block with code I wrote above, but I can't for the life of me think of an obvious solution although I'm sure this is a fairly commonplace problem in web development.

View Replies


ADVERTISEMENT

JSF :: How To Convert Hashmap Values To Arraylist To Display On Page

Apr 2, 2015

I need assigning the selected hashmap values into a list and to display the values in a jsf page. The user will select certificates and will be stored in the below list:

private List<String> selectedCertificates = new ArrayList<String>();

The selectedCertificates will have the values ("AA","BB"). Now I will be passing the list into a hashmap in order to get the names and to display them on the jsf page.

My code is below:

Map<String, String> CertificatesNames =
new HashMap<String,String>(selectedCertificates.size());
CertificatesNames.put("AA", "Certificate A");
CertificatesNames.put("BB", "Certificate B");
CertificatesNames.put("CC", "Certificate C");
for(String key1: selectedCertificates) {
System.out.println(CertificatesNames.get(key1));
}

I want to display in my jsf page :

Certificate A
Certificate B

Now my issue is that is how to display all the values of the CertificatesNames.get(key1) in the jsf page as I tried to do the below and it printed all the values when I used the #{mybean.beans} using the :

List beans =
new ArrayList(CertificatesNames.values());

So how to do this?

View Replies View Related

JSP :: Extracting Information About Previous Page From Where Current Page Came

Jan 31, 2015

I have to implement a system where I have to do almost same processing on a jsp page. The slight differences on the present page is based on whether the current page came from page 1 or page 2. So how can I do this?

View Replies View Related

JSF :: XHTML Page - Access To Content Of Dynamic Page?

Jan 15, 2014

I have a xhtml file that initialization it with ui:repeat tag in realtime.all tags of this page placed under ui:fragment tag.

<edges>
<ui:repeat value="#{graphInfoBean.edges}" var="edge" varStatus="indexVar">
<edge id="#{indexVar.index}" source="#{edge.source}" target="#{edge.target}"
weight="#{edge.weight}">

[Code] ....

When i access to this page and save it as xml in realtime, the tags in xml file saved is empty while it is initialized and everything is working properly.

<edges>
</edges>

How can i access to content of this xhtml page and save it on disk?

View Replies View Related

How To Use Multiple Textures On A Model

Jan 24, 2014

How can i use multiple textures on a model? I have the .OBJ loader and .MTL loader and everything is working fine. I can use a single texture. But i have a model that has 2 textures. How can i use both of the textures?

View Replies View Related

Boolean Retrieval Model Using SkipList

Oct 13, 2014

Boolean retrieval model using skiplist. I don't know how to code it. I have modified it but I'm not sure it work out. What are the modifications I can made.

/**My requirement is to implement two methods for Boolean Retrieval:

● index(String dir)
○ index()supposed to go over all files under "dir". There will be no subdirectories inside it.

● retrieve()
○ retrieve() supposed to return name of all the documents under "dir" that satisfies the given query. Note that, only basename of the files are to be returned, not the full path.
○ Query can be of two forms:
■ OR: returned doc should contain at least one term from the query.
■ AND: returned doc should contain all the terms from the query. **/

import java.util.HashSet;
import java.util.Vector;
public class BooleanRetrievalModel implements DocSearch {
// begin private class
private class SkipList {
// Node in skip-list

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Vector Is Used In ComboBox Model?

Sep 23, 2014

I understand how vectors work I'm currently using one to store my id's from my txt file but how do you put them in a defaultComboBoxModel?

DefaultComboBoxModel defaultComboBoxModel = new DefaultComboBoxModel();
//declare a vector object that will hold a string (only thing that works with comboboxmodel
Vector<String> myVector=new Vector<String>();
//try statement
try{
FileReader fr = new FileReader(file);

[Code]...

Any example of how a vector is used with a defaultComboBoxModel so I can then use that to populate my JComboBox?

View Replies View Related

Swing/AWT/SWT :: How To Format Value In Table Model

Nov 14, 2014

public PurchaseTableModel() {
try{
//establish connection
conn = DriverManager.getConnection("jdbc:odbc:SupplierDS");

stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);

[code]....

I get the value from database and display in table , price value will show 6 decimal and date value will show date and time.What to do to show only 2 decimal places and only date e.g. 1/1/2014 in the table ?

View Replies View Related

Swing/AWT/SWT :: Table Model Removal

Dec 18, 2014

I have 2 different bespoke table models.

When one is needed I simply add it to the table. In this case however whilst updating the model via table update in tableChanged method I have the impression of 2 identical models because the update happens twice (use of audio).

Is it not true that adding a new model cancels out the other ? I test for which model is attached to table and add the correct one depending on the data required.

assert (!(this.getTableModel() instanceof KeywordBeanTableModel));
this.initKeywordBeanTableModel();

View Replies View Related

Boolean Retrieval Model Implementation Using SkipList

Oct 11, 2014

/*
*
* You need to implement BooleanRetrievalModel using SkipList.
* You should have everything within this file.
*/

import java.util.HashSet;
import java.util.Vector;
public class BooleanRetrievalModel implements DocSearch {
// begin private class
private class SkipList {
// Node in skip-list

[Code] ....

View Replies View Related

Servlets :: New Instance Of Java Model For Each New Request

Oct 1, 2014

I want to create a new instance of a Java model class for each new request coming to a servlet.

How to do that without doing that in doGet() or doPost().

View Replies View Related

Implementation Of MVC With Several Viewers And Single Model / Controller?

May 6, 2014

I am working on an project in which some data needs to be received through socket , do some processing on it and then store on the database. After that it will display on GUI. GUI should be updated automatically.

I am able to implement basic model in which data is storing in the database and displayed then on the GUI. I tried to implement MVC design patter as well.

Now i need to create a GUI which can be used by several users at a time means several jvm session for the GUI. I got struck at this point.

Some detail: i have one jvm session in which i am receiving , processing and storing the data. Now i want to fire an alert whenever any new entry is made into the database. Also each time new GUI is opened it should be registered with the model so that model send updated data alert to all this users.

When i am trying to open several GUI and trying to register with the Model then it is not increasing count of registered user. For each time it is showing 1 count only and whenever a new entry is made count is showing 0. Is it because both are running in different jvm sessions ?

Some code for the model which is running in different package and jvm

GUI..

private void runApp() {
//some gui code
WindowListenerClass windowListener = new WindowListenerClass(this);
frame.addWindowListener(windowListener)
//registering viewer with the model
Model.setNewAlarmEvent(this);
tableModel = windowListener.getDefaultTableModel();

[Code] .....

View Replies View Related

Creating Table Model For Data From Database

Sep 9, 2014

I'd like to create my own Table Model to handle data from an SQLite database using JSwing, but I'm having difficulty. How to confirm the following:

-- A table model is an object that contains methods for manipulating data in the table, right?

If that's the case, then how should I create a Table Model to handle data coming from a database. From what I understand...

My custom Table Model needs to subclass AbstractTableModelI then override 3 methods from AbstractTableModel (getRowCount(), getColumnCount(), getValueAt())

As it relates to drawing data from a database, how should I be thinking about this problem (i.e. creating a Table Model that can work with a database)?

View Replies View Related

Model Galaxy - Multiple Stars With Different Masses

Mar 12, 2014

Here is a link to the program: [URL] ....

I am trying to model a galaxy so that I have multiple stars certain distances away from each other and with different masses.

The accretion and than cylinder expansion happens with just about every galaxy.

I have a few questions.

First My computer only runs this if the number of particles is in the 500s. If that's the case How can I increase the probability that I will when I get to it have a red giant?

Second how can I modify this so that I have a timescale during which white dwarfs form from some stars and you see in the single stars either no supernova or nova just degeneration or a type 2 supernova and in binaries a type 1a supernova which is like a type 2 supernova of 1 star when it is a red giant, that giant becoming a white dwarf, the other star becoming a red giant, and then the white dwarf sucking gas from the giant until it explodes and ejects its companion?

Third how can I make this compacted and taking up less space in case I want to expand it to a few galaxies or even start with a big bang?

Basically what I am asking is how can I make this like a universe?

View Replies View Related

Import Txt File In Abstract Table Model

Jan 16, 2014

I have a AbstractTable and would like to import a txt file into it. I know how to do it for a Default Table but I am not allowed to use it.

// Import Filechooser
public static ActionListener importChooseFileButtonListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser jfc = new JFileChooser();
int returnVal = jfc.showOpenDialog(jfc);
ImportPopup imp = new ImportPopup();

[Code] ....

What do I have to do to import the file into the table?

View Replies View Related

Massive Data Processing Using Unified Model

Dec 11, 2014

I have a requirement where we have an ETL jobs that runs in the backend which will get the up to date data from various sources , here we have both structured and unstructured data and the data capacity is massive which is in petabytes. Based on the data that is fetched we need to come up with a consolidated data view for the data which we retrieved. My queries are:-
 
1) How to create a consolidate data view , in what form it will be in (XML, JSON, etc)? whether we need to come up with a unified data model as the data is both structured and unstructured format? If so how we can go about it?

2) Since the data is really massive, how we can construct the consolidate data view? whether we need to create it in small chunks or whether we need to store these data in a cache or DB from where we will retrieve it and form the consolidated data view?

3) To process these data whether we need to have any Hadoop clusters to process these data parallel? As we are talking about massive data in the form of structured and un structured format?

4) Whether there is a need for NoSQL database to support unstructured data? If we are supposed to store the data?

View Replies View Related

JavaFX 2.0 :: Implement Multiple Selection Model?

Jul 16, 2014

I have tried to implement MultipleSelectionModel with mostly success in TreeView, but definitely with quirks. I've looked at the implementation in TreeView and it's off putting to say the least. Hopefully it doesn't need to be that complicated. For now, all I need is it to handle SINGLE SELECTION, but it needs to be solid. I've put in a lot of println's to see what gets called. Most don't seem to be called. I'm relying on TreeView to look up the object being selected, I'm not sure if that's appropriate. The internal implementation seems to worry about tree state a lot.
 
It baffles me as to why there isn't a base class from which to extend or reuse? I'm doing this so I can delay a selection (make it vetoable), also to handle drag/drop more cleanly (so target won't move because of drag action).
 
    private class VSelectionModel extends MultipleSelectionModel {
        List<Integer> baseSelectedIndexes = new ArrayList<>();
        ObservableList<Integer> selectedIndexes = FXCollections.observableList(baseSelectedIndexes);
        List<Object> baseItems = new ArrayList<>();
        ObservableList items = FXCollections.observableList(baseItems);
 
 [Code] ....

View Replies View Related

JSP :: How To Open Page Inside Another Page

Apr 1, 2015

I have two jsp page one is demo1.jsp and other is demo2.jsp on a click of a particular link on demo1.jsp I want to opwn demo2.jsp inside demo1.jsp without changing layout of demo1.jsp..I tried to use <jsp;include but that doesn't work for me.But how to do this simply on a single link click on a big page?

View Replies View Related

JSF :: Model Of Backing Beans / Separated Class Or Just Properties?

May 29, 2014

I have seen in some examples like URL... a good design is to have the model and the action methods in one just single bean and the model not to be a separated class but a few properties like this:

public class CustomerBean implements Serializable{
//DI via Spring
CustomerBo customerBo;
[b]public String name;[/b]
[b]public String address;[/b]
//getter and setter methods

[code]...

Some questions:

1. If you are using hibernate or any other ORM like the above example(URL...), why not to use the hibernate pojo bean directly like it represented the form instead of using properties?:

public class CustomerBean implements Serializable{
//DI via Spring
CustomerBo customerBo;
[b]Customer customer;[/b] //represents the properties of a form
//getter and setter methods
public void setCustomerBo(CustomerBo customerBo) {
this.custom

2. Why is it said that JSF represents the purest MVC? Spring separates the model from the view too and Struts does too. I dont really understand it

View Replies View Related

Design - How Map Request Parameters Data To Domain Model

May 24, 2014

This is a design question is the same problem in any language.as you do to map the controller to the domain model?We have situations in general larger than ... consider the example objects .

situation.1 - We have a request that has all the parameters of the account ;{ " id" : " 1 " , "name " : "test " , "some " : " xxx " } ............. and other fields .

situation.2 - can request that has to have a certain account parameters , for example in the case of an update;{" id" , " 1" , "name " , " testUpdated "}

situation.3 - We have a request that has some parameters of the account , others have more like id as user together;{ " id" : " 1 " , "user " : " xxx " , "service " : " yyy " } in which case each piece of the request will turn an object .

Java Code:

public class Account {

private Long id;
private String name ;
private String some ;

} mh_sh_highlight_all('java');

I see a few options ;

1 - Can I get AccountForm in the controller and set the properties for the Account object and others in CONTROLLER ;

+ ok for situation.1 situations 2, and situation.3

+ Separates the requisition of the object domain

- Pollutes the controller with code conversion

- Controller is full of setters .. if a higher class as a large object as a request is very confusing .

Java Code:

controller ( AccountForm from ) {
Account account = new Account ( )
account.setNome form.getNome = ();
account.setSome form.getSome = ();
Other outher = new Other ( ) ;
other.setSome ( form.getSome ( ) ) ;
} mh_sh_highlight_all('java');

2 - Can I get AccountRequest in the controller and have a method in itself as AccountRequest.getAccount ( ) to return a mapped model , in this case the mapping is at own Request object .

+ Separates the requisition of the object domain

+ Encapsulates the conversion in a place with easy access .

+ Meets situation.1 situation.2 and situation3 ;

- Request object has two responsibilities represent the request and map to a valid model .

Java Code:

controller ( AccountForm accountRequest ) {
Account account = accountRequest.getAccount ( ) ;
Outher outher accountRequest.getOther = ( )
} mh_sh_highlight_all('java');

3 - Can I get the controller Direct Account which had been filled with nulls .

+ Eliminate object request

- Serves only situation.1 situation.2 .

Java Code:

controller (Account account ) {
account.someMethod ();
} mh_sh_highlight_all('java');

4 - Outsource this mapping request parameters to another object mapper for request ..

+ Isolates logic mapping

- Until complexity for simpler cases are used as standard for all such a find by id .

- One more class for each request ;

In the case of API gets worse response has two further classes. speaking in terms of request for response .... AccountRequest, AccountRequestMapper, Account, AccountResponseMapper, AccountResponse .....I'm doing more testing the Hybrid option 3 for simple cases (find ID or updates) .... with option 2 for example for more complex cases ..

View Replies View Related

How To Make A Model Of Solar System - Have Sun And Earth Revolving Around It

Oct 25, 2014

I'm attempting to make a model of the solar system. Up till now, I have a Sun and the Earth revolving around it. The problem I have is when I add inheritance to the program. The moon that I created does not orbit the Earth.

Here's my code for the classes I've created

public class Driver {
public static void main(String[] args){
SolarSystem model = new SolarSystem(700, 700);
/* Create new instances of each object in the solar system */
SunObject sun = new SunObject();
PlanetObject earth = new PlanetObject(140, 30, 15, "BLUE", 2);
MoonObject moon = new MoonObject(15, 30, 2, "WHITE", 1.5);

[Code] ....

Note that SolarSystem is a class given to me. That contains all the paint methods. I'm just creating new instances with the drawSolarObject()

And the drawSolarObjectAbout takes an extra two parameters:

centreOfRotationDistance - the distance part of the polar co-ordinate about which this object orbits.
centreOfRotationAngle - the angular part of the polar co-ordinate about which this object orbits

I have a PlanetObject class:

public class PlanetObject extends PointInSpace {
private double distance;
private double angle;
private double diameter;
private String colour;
private double speed;

[Code] ....

And a MoonObject class, which is EXACTLY the same as the PlanetObject class. The main problem I'm having is when I extend my PlanetObject class to a PointInSpace class below:

public class PointInSpace {
private double distance;
private double angle;
public double getPointDistance(){
return distance;

[Code] .....

What I'm trying to do is use the distance and angle in the PointInSpace class so that my Moon can orbit those two coordinates . I get it working when I method override when drawing the moon - using earth.getDistance() instead of earth.getPointDistance() etc. Have I inherited properly? Should I try a method overloading process instead?

View Replies View Related

JSF :: Registering Model Services As ServletContext Attributes Using ServletContextListener

Aug 11, 2014

I am making an application in which I have to make the model (the services) available to the entire application so that all beans can access it and call its methods during the life of the application.

I am using the following technologies:
view: JSF 2.x
beans: Spring 4.x beans

The design problem I am having is the following:I came up with the idea of registering the model services as ServletContext attributes using my ServletContextListener, effectively making the services available to the entire application:

//imports
public class MyContextListener implements ServletContextListener {
//model services
private UserService userService;
private RepairService repairService;
public void initCafe()
{
userService.removeAllUsers();
repairService.removeAllRepairs();

[code]....

Shouldn't I just use @Autowired userService and @Autowired repairservice everywhere I want to use these services application-wide?Or is this a problem because beans have a default scope of Request? I am confused.

View Replies View Related

Swing/AWT/SWT :: Updating DefaultTable Model - Placing Text?

Jul 2, 2014

I have been going in circles trying to update a JTable. For now I just need to take input from a textfield after clicking on a JButton and have that text be placed in the JTable. LeftPanel listens, while RightPanel holds the table. Here is what I have so far:

package reminder.views;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class LeftPanel extends JPanel {

]Code] ....

View Replies View Related

JavaFX 2.0 :: Worker Threads - Created By Model Or By Controller?

Dec 8, 2014

Sometimes models needs to access blocking devices, like network cards, databases, files, and so on. This should be done by worker threads or services. But who is in charge of that? The controller or the model itself? I tend to say it is the model, as only the model knows about the fact that it accesses a blocking object. On the other hand, it is said that a model should be a POJO, so it would be the controller's job. Is there a best practice or general design rule?

View Replies View Related

JavaFX 2.0 :: Synchronize Model Representing Complex UI Composite With FlowPane Backing List

Aug 26, 2014

What is the best way to synchronize a Model representing a complex UI composite w/ a FlowPane's backing list?
 
Currently I have a change listener on the Model.  Upon an add I create a new UI composite and manually add it to the FlowPane's backing list via flowPane.getChildren().add().  Similarly if there is a remove, I iterate over the FlowPane's children, grab the right Node, and remove it.  Similarly, if there is a modification detected, I iterate over the FlowPane's children, grab the right Node, remove it, recreate the UI composite, and re-add it to the list.  I also need the list to be sorted, so I implemented a UIComposite comparator and call FXCollections.sort() on the FlowPane's backing list.  I feel like that is hacky, but it works.  It would be cool if I could maintain sort order in my model somehow and have that automatically propogated to the FlowPane's list.
 
I am correct in assuming that there is no way to have a complex binding in between an ObservableList<CompositeViewModel> and the FlowPane's backing list (ObservableList<T>)? 

Some kind of translator that could create a new UIComposite whenever there is a new CompositeViewModel added to the Model list.

View Replies View Related

How To Get Value For Key In Hashmap

Sep 26, 2014

In my code I read in a file of states and statecapitals then store them into a hashmap. I then ask the user what the capital is for the random state displayed.The problem I am having is getting the value for the random generated state. When I enter the correct capital for the state, it is still being marked incorrect. Here is my code.

Java Code: try {

Scanner scanner = new Scanner(file);
String[] values;

[code]....

View Replies View Related







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