Title: Message
Well, you don't HAVE to use an Action for this, but seeing your JSP I would HIGHLY recommend it. It's much nicer to put code into Actions than in scriptlets in your page.
 
I assume this is WW 1.3? I think the way to access this would be like this, if you decide to stick with building the list in your JSP:
 
<ww:select label="'Company'" name="'companyId'" list="@companies" listKey="'id'" listValue="'name'"/>
 
Let us know if this works for you,
 
Jason
-----Original Message-----
From: Chris Widhelm [mailto:[EMAIL PROTECTED]
Sent: Friday, August 29, 2003 2:38 PM
To: [EMAIL PROTECTED]
Subject: Re: [OS-webwork] ui:select problems

Here is the exact page.
 
Maybe I am doing something completely wrong.  I was not aware that I needed to use an action to make the List available.  I thought the tag library would just use the page context.
 
======================================================
 
<%@ page
  import="com.contego.arx.domain.Company,
      org.apache.ojb.broker.query.QueryByCriteria,
      org.apache.ojb.broker.query.Query,
      org.apache.ojb.broker.query.Criteria,
      java.util.Collection,
      java.util.List,
      java.util.ArrayList" %>
 
<%@ taglib uri="sitemesh-page" prefix="page" %>
<%@ taglib uri="/WEB-INF/classes/webwork.tld" prefix="ww" %>
 
<%
QueryByCriteria q = new QueryByCriteria( Company.class, null );
q.addOrderBy( "name", true );
List companies = (List)Company.list(q);
%>
<%=companies.size() %>
<page:applyDecorator name="admin">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
 <tr>
  <td>
  <form action="" method="get">
    <ww:property>
      <ww:textfield label="'First Name'" name="'FName'"/>
      <ww:textfield label="'Last Name'" name="'LName'"/>
      <ww:textfield label="'Email'" name="'email'"/>
      <ww:textfield label="'Phone'" name="'phone'"/>
   <ww:select label="'Company'" name="'companyId'" list="companies" listKey="'id'" listValue="'name'"/>
    </ww:property>
  <input type="submit"/>
  </form>
  <webwork:iterator value="errors">
    <br><webwork:property/>
  </webwork:iterator>
  </td>
 </tr>
</table>
</page:applyDecorator>
 
======================================================
----- Original Message -----
Sent: Friday, August 29, 2003 12:50 PM
Subject: RE: [OS-webwork] ui:select problems

When you say "On the page I have created a java.util.List called "companies"." what do you mean?
 
The tag will look for a property name 'companies' in your Action with a getCompanies() method. Depending on which WebWork version you're using (1.x or 2.0) there's different ways for retrieving objects in the page context. Is this what you're trying to do?
 
Jason
-----Original Message-----
From: Chris Widhelm [mailto:[EMAIL PROTECTED]
Sent: Friday, August 29, 2003 11:03 AM
To: [EMAIL PROTECTED]
Subject: [OS-webwork] ui:select problems

I am trying to get the select tag to generate a select from a java.util.List containing a class called Company.  Here is the tag that I have used in my JSP.
 
   <ui:select label="'Company'" name="'companyId'" list="companies" listKey="'id'" listValue="'name'"/>
 
On the page I have created a java.util.List called "companies".  The Company class has two attributes; "id" and "name".  Each of these attributes has their respective accessor and mutator.  What am I doing wrong?
 
Thanks for any help,
 
Chris
 

Reply via email to