array in javabean and access from jsp

Q

Quick Function

I am writing a javabean for jsp. Here is my example:

public class MyBean implements java.io.Serializable {

private String name;
private String[] account;

public MyBean(){....}

public String getName(){
return name;
}

public void setName(String name){
this.name = name;
}

public String getAccount(int index){
return account[index];
}

public String setAccount(int index, String account){
this.account[index] = account;
}
}

Is this bean? Good for Jsp? How can I set and get the account array in jsp?

Thanks,

qq
 
H

Hal Rosser

you need a set and get for the array

Quick Function said:
I am writing a javabean for jsp. Here is my example:

public class MyBean implements java.io.Serializable {

private String name;
private String[] account;

public MyBean(){....}

public String getName(){
return name;
}

public void setName(String name){
this.name = name;
}

public String getAccount(int index){
return account[index];
}

public String setAccount(int index, String account){
this.account[index] = account;
}
}

Is this bean? Good for Jsp? How can I set and get the account array in jsp?

Thanks,

qq
 
H

homecurr

Hal Rosser said:
you need a set and get for the array

Quick Function said:
I am writing a javabean for jsp. Here is my example:

public class MyBean implements java.io.Serializable {

private String name;
private String[] account;

public MyBean(){....}

public String getName(){
return name;
}

public void setName(String name){
this.name = name;
}

public String getAccount(int index){
return account[index];
}

public String setAccount(int index, String account){
this.account[index] = account;
}
}

Is this bean? Good for Jsp? How can I set and get the account array in jsp?

Thanks,

qq


How can I set the array from jsp?

Thanks,

qq
 
H

Hal Rosser

public String[] getAccounts(){
return account;
}

You have an ARRAY named account
you need a get and set method for the array
you can still have the other get and set methods to return an ELEMENT
but ya gotta have one for the array too

homecurr said:
"Hal Rosser" <[email protected]> wrote in message
you need a set and get for the array

Quick Function said:
I am writing a javabean for jsp. Here is my example:

public class MyBean implements java.io.Serializable {

private String name;
private String[] account;

public MyBean(){....}

public String getName(){
return name;
}

public void setName(String name){
this.name = name;
}

public String getAccount(int index){
return account[index];
}

public String setAccount(int index, String account){
this.account[index] = account;
}
}

Is this bean? Good for Jsp? How can I set and get the account array in jsp?

Thanks,

qq


How can I set the array from jsp?

Thanks,

qq
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top