Ummm, i apologize.....I made a very simple mistake:
<s:select name="database" list="databases" listKey="id"
listValue="database" "emptyOption="true"></s:select>
I put an extra " in the select tag.
On Wed, 2007-09-12 at 14:35 -0700, Randall Svancara wrote:
> <SORRY, I SENT THIS TOO EARLY>
>
> I mostly have experience with original struts. But now I am attempting
> to use Struts 2. I am trying to figure out how I can populate the
> select tag.
>
> I have created an action class, called Blast with the following
> attributes:
> 1. List<Database> databases = new ArrayList();
>
> There are two methods, getDatabases and setDatabases
>
> I have created another class called Database with the following
> attributes:
> 1. int id
> 2. String database
> 3. String databasetype
>
> I want to use the select tag to access the List of Database objects in
> the action class Blast.java
>
> This is how I am using the action class:
>
> <s:select name="database" list="databases" listKey="id"
> listValue="database" "emptyOption="true"></s:select>
>
> As you can see, I specify the list equal to databases which should
> correspond to getDatabases in my action class, Blast. My listKey is
> equal to id, which should correspond to the id field in my Database
> class. And finally, listValue should correspond to database in my
> Database class.
>
> My jsp page fails to compile/execute giving errors like:
>
> /view/Index.jsp(55,87) Unterminated <s:select tag
>
> or
>
> org.apache.jasper.JasperException: Unable to load class for JSP
>
> I am including copies of the files in case someone is kind enough to
> help a pathetic newbie out with this.
>
> <BLAST.Java>
> mport java.io.File;
> import java.util.ArrayList;
> import java.util.Collections;
> import java.util.Date;
> import java.util.HashMap;
> import java.util.List;
> import java.util.Map;
>
> import org.apache.struts2.ServletActionContext;
>
> import com.opensymphony.xwork2.ActionSupport;
> import com.opensymphony.xwork2.Validateable;
> import com.opensymphony.xwork2.util.ValueStack;
>
> import edu.wsu.bioinfo.domain.Database;
>
> import org.apache.log4j.Logger;
>
> public class Blast extends MainLabSupport {
>
> static final long serialVersionUID=1L;
> private static Logger logger = Logger.getLogger(Blast.class);
>
>
> private String title;
> private String emailaddress;
> private String database;
> private List<Database> databases = new ArrayList();
>
> // Default Constructor
> public Blast(){
>
> Database db1 = new Database(1, "NCBI Fragaria EST", "EST");
> Database db2 = new Database(2, "NCBI Malus EST", "EST");
> Database db3 = new Database(3, "NCBI Prunus EST", "EST");
> this.databases.add(db1);
> this.databases.add(db2);
> this.databases.add(db3);
>
> }
>
>
> public String execute() throws Exception {
>
>
>
>
> return INPUT;
> }
>
>
> /**
> * @return the title
> */
> public String getTitle() {
> return title;
> }
>
>
> /**
> * @param title the title to set
> */
> public void setTitle(String title) {
> this.title = title;
> }
>
>
> /**
> * @return the emailaddress
> */
> public String getEmailaddress() {
> return emailaddress;
> }
>
>
> /**
> * @param emailaddress the emailaddress to set
> */
> public void setEmailaddress(String emailaddress) {
> this.emailaddress = emailaddress;
> }
>
>
> /**
> * @return the database
> */
> public String getDatabase() {
> return database;
> }
>
>
> /**
> * @param database the database to set
> */
> public void setDatabase(String database) {
> this.database = database;
> }
>
>
> /**
> * @return the databases
> */
> public List<Database> getDatabases() {
> return databases;
> }
>
>
> /**
> * @param databases the databases to set
> */
> public void setDatabases(List<Database> databases) {
> this.databases = databases;
> }
>
> }
>
>
> <Database.java>
>
> public class Database {
>
> private int databaseid;
> private String database;
> private String databasetype;
>
>
> /**
> * Default Constructor
> */
> public Database(){
>
> }
>
> /**
> * Constructor with parameters
> * @param databaseid
> * @param database
> * @param databasetype
> */
> public Database(int databaseid, String database, String databasetype){
> this.databaseid = databaseid;
> this.database = database;
> this.databasetype = databasetype;
> }
>
> /**
> * @return the databaseid
> */
> public int getDatabaseid() {
> return databaseid;
> }
> /**
> * @param databaseid the databaseid to set
> */
> public void setDatabaseid(int databaseid) {
> this.databaseid = databaseid;
> }
> /**
> * @return the database
> */
> public String getDatabase() {
> return database;
> }
> /**
> * @param database the database to set
> */
> public void setDatabase(String database) {
> this.database = database;
> }
> /**
> * @return the databasetype
> */
> public String getDatabasetype() {
> return databasetype;
> }
> /**
> * @param databasetype the databasetype to set
> */
> public void setDatabasetype(String databasetype) {
> this.databasetype = databasetype;
> }
>
> }
>
> <Index.jsp>
>
> <s:form action="index" enctype="multipart/form-data">
> <table>
> <tr>
> <td>
> Search Title:
> </td>
> <td>
> <s:textfield name="title" size="50"></s:textfield>
> </td>
> </tr>
> <tr>
> <td>
> Email Address:
> </td>
> <td>
> <s:textfield name="email" size="50"></s:textfield>
> </td>
> </tr>
> <tr>
> <td>
> Database:
> </td>
> <td>
>
> <s:select name="database" list="databases" listKey="id"
> listValue="database" "emptyOption="true"></s:select>
> </td>
> </tr>
> </table>
> <div class="tabber">
> <div class="tabbertab">
> <h2>Upload File</h2>
> File: <s:file name="testfile" size="50"></s:file>
> </div>
> <div class="tabbertab">
> <h2>Cut and Paste</h2>
> Paste Sequence into Text Area:<br />
> <s:textarea tooltip="Cut and Past your sequence" cols="80"
> rows="8" name="sequence" label="Sequence">
> </s:textarea>
> </div>
>
> <s:select name="searchBy" list="#{'01':'Begins with',
> '02':'Contains', '03':'Equals'}" />
> </div>
>
>
> <s:submit />
> <s:reset />
>
> </s:form>
>
>
> <End of Transmission>
>
>
> On Wed, 2007-09-12 at 14:27 -0700, Randall Svancara wrote:
> > [email protected]
--
Randall Svancara
System Administrator
Horticulture and Landscape Architecture
509-335-7093
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]