Bandula,
To be consistent.
It is better practice to make your view layer interact with the action support
controller struts MVC framework.
If this is the case the your taskForm.jsp should be tied to TaskAction.java
which should be your action class.
In you Action class declare
private List availableStatuses;
private static final PENDING = "PENDING";
private static final OPEN = "OPEN";
private static final DONE = "DONE";
private static final HOLD = "HOLD";
Then have a method in your action class.
public List getAvailableStatuses(){
if(availableStatuses != null){
return availableStatuses;
} else {
availableStatuses= new ArrayList();
availableStatuses.add(PENDING);
availableStatuses.add(OPEN);
availableStatuses.add(DONE);
availableStatuses.add(HOLD);
return availableStatuses;
}
}
In your taskForm.jsp
you add
<s:select label="Available Status"
name="StatusPojo.status"
headerKey="1"
headerValue="-- Please Select --"
list="availableStatuses"
/>
Make the appropriate declarations in your struts config and applicationContext
to hook you action, pojo and jsp.
Hope this helps.
Paul Were.
"Richard Mixon (CustCo)" <[EMAIL PROTECTED]> wrote:Re: [appfuse-user] Drop-Down
List Im pretty new to Struts2 myself, but all of my Appfuse Struts2 pages
use a select tag something like this:
<s:select name="storyText.status.id"
list="activeStatusList" listKey="id" listValue="name"
key="storyText.status"/>
I think your tag looks more like a Struts(1) tag.
Here is the Struts2 reference page for the select tag:
http://struts.apache.org/2.0.11.1/docs/select.html
Hope this helps.
---------------------------------
From: Bandula Rathnasekara <[EMAIL PROTECTED]>
Reply-To: <[email protected]>
Date: Sun, 1 Jun 2008 12:36:01 +0530
To: <[EMAIL PROTECTED]>
Cc: <[email protected]>
Subject: [appfuse-user] Drop-Down List
Hi all,
I want to add simple drop down list in a JSP page with my Struts2 web
application on AppFuse framework. I went through related post in web and tried
to do it with StartupListener class.
I created/modified following classes/jsp.
1. Created Statuses POJO.
Not used for the time being
2. Constant
public static final String AVAILABLE_STATUSES = "availableStatuses";
3. StartupListner
context.setAttribute(Constants.AVAILABLE_STATUSES ,
mgr.getObjects(TaskStatuses.class));
4. LookupManager
public List<LabelValue> getObjects(Class<TaskStatuses> name);
5. LookupManagerImpl
public List<LabelValue> getObjects(Class<TaskStatuses> name) {
List<LabelValue> list = new ArrayList<LabelValue>();
list.add(new LabelValue("PENDING", "PENDING"));
list.add(new LabelValue("OPEN", "OPEN"));
list.add(new LabelValue("DONE", "DONE"));
list.add(new LabelValue("HOLD", "HOLD"));
return list;
}
6. taskForm.jsp
<html:select property="status">
<html:options collection="availableStatuses" property="status"
labelProperty="name"/>
</html:select>
I was struggling with this whole yesterday and I could not populate drop
down-list in my jsp. I dont even get error in JSP page. Is it do something
with tag libraries in? Any configuration XML file? Can you tell me where else I
need to change/correct.
If anyone has sample code on this or a place where I can find them pls let me
know.
Thanks &Regards,
Bandula