JSF :: Passing Parameters From Normal List Object Without Using DataModel

Oct 9, 2014

How to use the id parameter in my documents entity to download documents from a list of documents. Normally I use ListDataModel and the getRowData method. I would like to know how to achieve the same thing using an ordinary List object.

My list of documents is called List<CountryDocs> selectedDocs;

<h:form>
<p:dataTable value="#{countryDocBean.selectedDocs}" var="docs">
<p:commandLink id="download" value="Download" ajax="false">
<p:fileDownload value="#{countryDocBean.downloadedFile}"
contentDisposition="attachment"/>

[Code] ....

Clicking on the download link calls the following method in my managed bean:

@ManagedBean(name = "countryDocBean")
@SessionScoped
public class CountryDocBean {
private List<CountryDocs> selectedDocs;
public StreamedContent getDownloadedFile() {

[Code] ....

Debugging shows the value for the id is 0 and this results in a NullPointerException. I've tried several methods for grabbing the document id in my backing bean, but no luck yet. I also read about the the ViewParams and ViewAction method but they caused validation errors to do with the <f:metadata> tags. I don't know how to obtain this value using a normal List object.

View Replies


ADVERTISEMENT

JSF :: Passing Parameters From Servlet

Sep 12, 2014

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.

sourceId=j_idt2[severity=(ERROR 2), summary=(j_idt2: '45;productType=Sport'

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());

[Code] ....

View Replies View Related

BufferedReader - Passing Parameters

Mar 7, 2015

Using Eclipse. I have this line of code:

BufferedReader br = new BufferedReader(new InputStreamReader(in));

I want to do something with br in a method that I defined. But Eclipse is complaining about br declared as

public static void Get_Next(String next_line, BufferedReader br) {

How do I make this work?

View Replies View Related

JSP :: Passing Dynamic Parameters Through Href Tag

Aug 3, 2011

I am trying to pass additional information through <a href> tag

<a href="welcome.jsp & param=<%=add.getID()%>">Welcome </a>

The error is : HTTP Status 404 - /WebApp/welcome.jsp & param=6

The id obtained from add.getID() is displayed in address bar on the browser.

I want to use this id on the next page. I try to use :

request.getParameter("param");

But could not get the ID....

View Replies View Related

JSF :: Passing Argument Parameters Between Pages

Jul 19, 2014

So I have an application where the user logs in (using j_security_check). User is taken to a welcome page where user's name is displayed as a link. When clicking that link I would like to take the user to a page where the user is able to update the credentials (password, address, etc). In this way the user only has access to the link related to that specific user's credentials. I am trying the following structure:

The welcome page (adminindex.xhtml) is:

<h:form>
Welcome to admin <h:commandLink value="#{userb.loggedUser}" action="#{userb.selectedUser}"/>
<f:param name="userName" value="#{userb.userName}"/>
</h:form>

The user backing bean:

public String selectedUser() {
userName = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(userName);
selUser=uServ.findByName(userName);
return "UpdateUser";

[Code] ....

The last line of the stack suggests that a null PK value is being picked up by the FacesContext method in the backing bean. I'm confused because the userName string IS the primary key of the user table which is structured like this:

CREATE TABLE sha_users
( username VARCHAR(255) NOT NULL
, password VARCHAR(255) NULL
, PRIMARY KEY ( username ) );

I'm sure I'm getting the concept of how to pass query parameters...

View Replies View Related

JSP :: Passing Parameters To Custom Tag Error

May 14, 2014

I am not able to pass parameters to custom tag. This is my tag file header.tag under web-in/tags folder

<img ><br>
<b><i>${subTitle}</i></b>

And This is my jsp page that use that tag.

<%@ taglib prefix="myTags" tagdir="/WEB-INF/tags" %>
<html>
<body>
<myTags:header subTitle="We make sure our clients dont have to do that" />

</body>
</html>

It says attribute subTitle invalid for tag header according to TLD.

View Replies View Related

Passing Parameters And Return Statement

Apr 27, 2014

My task is to make a mortgage calculator where the user selects which calculation they want the program to do via a menu. I got the menu to work and it keeps on looping until terminated so that's good. The starts when I want the user's choice (P, I or T) to be used in another method which will then execute another set of code (the calculation that needs to be done). I think passing parameters and return statements are what I need to use, but after reading and watching videos, I'm still not sure how to implement it into my program. For now, I want the user to input the letter "P" and then I want that information to be passed to the method, loanCalculator() where the if statement will make a decision to call the method, calcPayment and display the number 0 via the console. Once it can do that, I'll fill in the calculation methods with the proper code since I can at least navigate the user input to its associated calculator. It just keeps on looping the menu without going through the other methods.

import java.util.Scanner;
//Example of "big loop" in main to repeat using a No Trip (0,N) test first
public class Mortgage {
// constants
static double loanAmount;
static double interestRate;
static int term;

[code]....

View Replies View Related

Passing Parameters - Randomly Generated Numbers Not Appearing

Dec 14, 2014

For some reason, when I test out my code, my randomly generated numbers don't appear. Here is a sample result:

> What do you want to generate, integer, double, or character?

>integer

>What is the upper limit and lower limit of the integers you want to generate?

>1

>10

>How many integers do you want to generate?

>10

>BUILD SUCCESSFUL (total time: 9 seconds)

Is this because my code is not passing my parameters correctly? I'm not sure how to fix this either.

Here is my code for reference (it's not completed at the moment)

import java.util.Scanner;
public class NewNumberCharacter {
/** Main method
* @param args */
public static void main(String[] args) {
int return_int;
double return_double;

[Code] ....

View Replies View Related

How To Put Parameters To Object

Aug 2, 2014

So I created this line class and when I try to create Line object with parameters, I don't know how to pass the parameters properly. It has to return two points, so it should be like [(1,2),(5,12)].I tried different things likeLine l1=new Line(Point p1(1,2),Point p2(5,12)); and similar, but nothing worked.

package line;
import java.awt.Point;
public class Line {
private Point p1;
private Point p2;

[code]...

View Replies View Related

How To Have Unlimited Object Parameters In Constructor

Nov 21, 2014

I want to create an order system. My Problem is that I want to create it dynamic, with ArrayLists and no fixed Array size.

Basically I have already a User which is able to purchase something.

User a = new User();
Car car = new Car("blue",500);
a.purchase(new Order(new OrderThing(5,car));

This will work!

But I want something like this:

a.purchase(new Order(new orderThing(5,car), new orderThing(2,car), new OrderThing(1,car),...)

Basically I don't know how much OrderThings I want to create before I type in the OrderThings with new Order().

But in java it is before you can construct orderThings you must already know in the constructer how much objects you do want.

Now as im writing this question I got a idea of waiting for an Array of new OrderThing but it don't work. When I write

a.purchase(new Order(new orderThing(5,car), new orderThing(2,car)))

it wants a constructor which is based on Order(orderThing,orderThing)

View Replies View Related

Sort Linked List Through The Nodes Of List - Data Of Calling Object

Feb 14, 2014

I have some class called sorted to sort the linked list through the nodes of the list. and other class to test this ability, i made object of the sort class called "list1" and insert the values to the linked list.

If i make other object called "list2" and want to merge those two lists by using method merge in sort class. And wrote code of

list1.merge(list2);

How can the merge method in sort class know the values of list1 that called it as this object is created in other class.

View Replies View Related

Passing Object As Parameter?

Aug 8, 2014

i want to pass an object of type Software to assign it to a computer from Computer class...

i should note that computer and software are arrays of objects thats the variable and method to set software in Computer class

private Software[] software;
public void setSoftware(Software software,int index){
this.software[index]=software;}

note: the user choses the a computer from a list and a software as will

for example the program will show the user 2 computers

0 for computer: apple, Model: mac mini, Speed: 2.8

1 for computer: sony, Model: vaio, Speed: 2.2

the user enters the index he wants then the program will show a list of software to add to the computer selected

the error I'm having is run time error Exception in thread "main" java.lang.NullPointerException and it points to these 2 lines

1.comp[Cch].setSoftware(software,Sch);

2. the method setSoftware

every thing is running correctly but this step above

Cch= the chosen computer index

Sch= the chosen Software index

why am i getting an error and how to fix it?

View Replies View Related

Get Object Strings To Print In List So That User Can Select That Object To Manipulate Its Attributes

Oct 7, 2014

I am new to Java and have read books, the Java docs, and searched the Internet for my problem to no avail. I have an Array of objects that contains strings. How can I get the object's strings to print in a list so that the user can select that object to manipulate its attributes? For example, the user can select "Guitar 1" from a list and manipulate its attributes like tuning it, playing it, etc. I have a class called Instruments and created 10 guitar objects.Here is the code:

Instrument [] guitar = new Instrument[10];
for (int i = 0; i < 10; i++) {
guitar[0] = new Instrument("Guitar 1");
guitar[1] = new Instrument("Guitar 2");
guitar[2] = new Instrument("Guitar 3");
guitar[3] = new Instrument("Guitar 4");
guitar[4] = new Instrument("Guitar 5");
guitar[5] = new Instrument("Guitar 6");

[code]...

View Replies View Related

Passing A Graphics Object To 3 Other Classes?

Oct 5, 2014

Basically I am making a paddleball game, like i'm sure everyone does in learning Java. I'm supposed to use different classes for each component, i.e. one for the ball, one for the paddle, and one for the display, then finally one as a 'controller' to implement mouselistener and stuff.

However, I can't quite grasp how to implement the paintComponent method. I know I can only have it in one class extended from JPanel, and I have the syntax for creating an object which I understand is something like this:

public void paintComponent(Graphics g){ //this is the rectangle my game will be played on,
super.paintComponent(g); //a gray background to define boundaries for the ball
g.setColor(Color.GRAY);
g.drawRect(0, 0, Frame.getHeight(), Frame.getWidth());

However what I don't understand is, how do I then pass this graphics object to the ball and paddle to let them draw themselves? I found something that described it like this here

class GamePanel extends JPanel {
Entity e=new Entity;
@Override
protected paintComponent(Graphics g) {
super.paintComponent(g);

[Code] .....

What I don't get is, if I use this, where would I put the drawRect and stuff to make the other shapes I need? in their class, under the entity.Draw(g) method? or in the display class where it calls the graphic object in the first place?

Last, how can I have my controller class refresh the displays of each of these with the timer I have implemented? Is there a simple way to call one refresh command and have it refresh the drawing of both the paddle and ball simultaneously, or would I need to call a separate refresh command for each object?

View Replies View Related

Passing Object Created In One Method To Another?

Oct 29, 2014

I am working on an independent project it is a simple little text based rpg that will run in a counsel window. I have an object for Character that is creating during a CreateCharacter method. I want the play to be able to enter a character that will open up a menu that displays things like the name and health and stuff of the character from the object created in CreateCharacter, but because I have it in a different class I don't know how to reference the object made in CreateCharacter.

I have it in 6 files

Character --- Object with getters/setters for things like name, age, race, class, ect
MainMenu --- Displays title and promts for new game and quit
CreateCharacter --- Walks through and sets all values in Character
Stats --- Keeps the players stats (health, attack, ect) in an array
Intro --- Beginning demo thing (not really important for this question)
Menu --- Displays all current user stats (Having issues with this one)

Example I have this in Menu

System.out.println("Name: " + ????.getName());

View Replies View Related

Display Properties Of Each Object Instead Of Object Array List Itself?

Mar 23, 2015

If I set a Jlist to contain an array of objects, how can I display properties of each object instead of the object array list itself. Ex:

Instead of:

Person1
Person2
Person3

display values such as each person name within the Jlist:

Mike
Paul
Andrew

View Replies View Related

Searching For Object In Linked List Then Removing The Object

Nov 19, 2014

I have just started working with linked lists. I have a linked list of Objects and I want to be able to search for a specific object. But currently my code continues to return false. Also how would I go about removing the first index of the linked list.

public static void main(String[] args) {
LinkedList<Cookies> ml = new LinkedList<>();
int choice = 0;
while (choice >= 0) {
choice = menu();

[Code] ....

View Replies View Related

Passing Object As Parameter - Combination Values Are All Zero

Mar 8, 2015

I have an object that has an instance of another object class as its parameter :

CombinationLock oneHundred = new CombinationLock(28,17,39);
Locker Mickey = new Locker(100, "Mickey", 3, oneHundred);

This is for a locker, which has a combination assigned to the student. Within the locker class I have the following constructor:

public Locker(int locker, String student, int numberOfBooks, CombinationLock combo) {
this.locker = locker;
this.combo = combo;
this.student = student;
this.numberOfBooks = numberOfBooks;
}

combo is the private CombinationLocker object I created within the Locker class. Do I need to pass the combo object on to the CombinationLock class? For reason, I do not comprehend, the combination password from the main class is not passing through to the CombinationLock class, and the combination values are all zero.

View Replies View Related

Passing Object From JSP Page Through JSTL Into Controller Method

May 12, 2015

I need to pass advanced object into controller from JSP page, but I always get null result.It's a controller method:

Java Code:

@RequestMapping(value="admin-user-edit", method=RequestMethod.POST)
public ModelAndView editUser(@ModelAttribute(value="user") UsersEntity user)
{
if (null == user)System.out.println("User is null");
else
System.out.println("User name = " + user.getName() + " | Users id = " + user.getId());
ModelAndView view = new ModelAndView();
return view;
} mh_sh_highlight_all('java');

And this is a JSP page snippet. I need to choose some user from user list and pass it to controller.

XML Code:

<c:forEach var="user" items="${user_list}">
<tr>
<td><c:out value="${user.id}" /></td>
<td><c:out value="${user.name}" /></td>
<td><c:out value="${user.login}" /></td>
<td><c:out value="${user.status}" /></td>

[code]...

I tried to pass it through HttpServletRequest argument but all the same.

View Replies View Related

Passing Parameter From Object Of Class B To Object Of Class C By Use Of Class A?

Dec 13, 2014

Assuming that we have two classes B and C which inherit from class A. What is the best way to pass a parameter from an object of class B to an object of class C by the use of class A without using static variable and without defining a get function in B?

View Replies View Related

Passing Object Argument To A Method - Unable To Call Methods On Argument

Feb 7, 2015

I am trying to pass an object of type Product p to my editProduct method, however trying to call p.getName(); doesn't work and throws a NullPointerException. The same kind of thing works for my displayRecord method (in a different class) and I can call .getName() on Product p, also passed as an argument to that method. Below is my editProduct class. The NullPointerExcepion is being thrown at line 61 (i.e., nameField.setText(p.getName());).

I don't know if I explained right, so here's a line thing of how the classes relate:

Search >>>(field.getText())>>> displayRecord(Product p) >>>editProduct(p)>>> EditProduct

And as a side note: adding the line p = new Product(); fixes it and successfully runs the class (including the Save and Quit parts) but obviously I want it to specifically refer to the Product I pass to the method.

Java Code:

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;

[Code] ....

I'm asking a question because I don't understand how Product p could possibly be null, because the argument is passed through my DisplayRecord class, which also takes a Product p argument and works. In that class, I have declared Product prod = p; and prod is what I am passing to editProduct.

View Replies View Related

Which Method Is Used While Passing Or Returning A Object From The Native Method

Mar 5, 2014

Which method is used while passing or returning a java object from the native method?

View Replies View Related

Iterate Over List And Get Values From Object?

Jan 22, 2015

first i looked at this example and understand this fine:

import java.util.ArrayList;
import java.util.Iterator;
public class Main {

[Code]....

View Replies View Related

Array List That Contain String Object

May 5, 2014

Suppose that you have an ArrayList and that it contains String objects. Which declaration of the ArrayList requires that objects retrieved using the get method be cast to Strings before calling a String method?

I. ArrayList a = new ArrayList();
II. ArrayList<Object> a = new ArrayList<Object>;
III. ArrayList<String> a = new ArrayList<String>;

A. I only
B. II only
C. III only
D. I and II only
E. I, II, and III

I know that all of these are ways to declare an Array List, but I am unfamiliar with the last two since I usually just declare my Array Lists with the first option.

View Replies View Related

How To Modify Property Of Object Stored In List

Jul 31, 2014

I'm facing a problem in below scenario:

List lst = tDAO.executeReport();

lst contains list of objects and one of the objects contains the property bDate(Timestamp) which has the value 28-2-1989 00:00:00.0, now I just wants to change the value into 28-2-1989 and store it back into the List as a Timestamp. how can I do that.

View Replies View Related

Deleting Complex Object In Java List

Sep 3, 2014

I am following those three tutorials and I have completed it with success.

( [URL] .... )
( [URL] .... )
( [URL] .... )

But then, as author haven't implemented removeCountries method I tried to create it. What I did initially was to just add to class Countries this method:

public boolean removeCountry(Country country) {
return countries.remove(country);
}

But although compiler wasn't complaining it didn't work. Actually it worked last night (before reboot) but not today. Must be some SOAP iterator/binding thing or whatever. Or I thought that it worked but in fact it didn't.

Here are original classes:

//-------------------------------
public class Country {
String CountryId;
String CountryName;
public Country() {
super();

[Code] ....

I would like to avoid my own iterator as JDeveloper can generate automatically iterators for webservices, but if I can't get it that way, what would be better way to write above mentioned iterator in removeCountry method?

Is there any way to remove object directly with something like this:

co.countries.remove(o);
co.removeCountry(country)

using method

// This left unused
public boolean removeCountry(Country country) {
return countries.remove(country);
}

from class Countries?

Parameters should be set by web service iterator.

View Replies View Related







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