Sample Application

Version 6 by Tim Fennell
on Jul 21, 2006 04:43.

compared with
Current by Remi VANKEISBELCK
on Feb 17, 2013 16:01.

(show comment)
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (45)

View Page History

{code:xml|title="BulkAddEditBugs.jsp"}
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="header.jsp" file="/bugzooky/taglibs.jsp" %>

<stripes:layout-render name="/bugzooky/layout/standard.jsp" title="Bulk Add/Edit Bugs">
<stripes:layout-component name="contents">

<div class="sectionTitle">Bulk Add</div>
<jsp:useBean id="componentManager" scope="page"
class="net.sourceforge.stripes.examples.bugzooky.biz.ComponentManager"/>
<jsp:useBean id="personManager" scope="page"
class="net.sourceforge.stripes.examples.bugzooky.biz.PersonManager"/>

<jsp:useBean id="componentManager" scope="page"
<stripes:form action="/examples/bugzooky/MultiBug.action" focus="">
class="net.sourceforge.stripes.examples.bugzooky.biz.ComponentManager"/> <stripes:errors/>
<jsp:useBean id="personManager" scope="page"
class="net.sourceforge.stripes.examples.bugzooky.biz.PersonManager"/>

<stripes:form action="/bugzooky/MultiBug.action">
<stripes:errors/>
<table class="display">
<tr>
<th>ID</th>
<th><stripes:label name="bugs.component.id"/></th>
<th><stripes:label name="bugs.owner.id"/></th>
<th><stripes:label name="bugs.priority"/></th>
<th><stripes:label name="bugs.shortDescription"/></th>
<th><stripes:label name="bugs.longDescription"/></th>
</tr>

<table class="display">
<tr>
<th>ID</th> <c:choose>
<c:when test="${actionBean != null}">
<c:set var="list" value="${actionBean.bugs}" scope="page"/>
</c:when>
<c:otherwise>
<c:set var="list" value="<%= new Object[5] %>" scope="page"/>
</c:otherwise>
<th>Component</th> </c:choose>
<th>Assignee</th>
<th>Priority</th>
<th>Status</th>
<th>Short Description</th>
<th>Long Description:</th>
</tr>

<c:forEach items="${list}" var="bug" varStatus="loop">
<tr>
<td>
${bug.id}
<stripes:hidden name="bugs[${loop.index}].id"/>
</td>
<td>
<stripes:select name="bugs[${loop.index}].component.id">
<stripes:option value="">Select One</stripes:option>
<stripes:options-collection collection="${componentManager.allComponents}"
label="name" value="id"/>
</stripes:select>
</td>
<td>
<stripes:select name="bugs[${loop.index}].owner.id">
<stripes:option value="">Select One</stripes:option>
<stripes:options-collection collection="${personManager.allPeople}"
label="username" value="id"/>
</stripes:select>
</td>
<td>
<stripes:select name="bugs[${loop.index}].priority">
<stripes:option value="">Select One</stripes:option>
<stripes:options-enumeration enum="net.sourceforge.stripes.examples.bugzooky.biz.Priority"/>
</stripes:select>
</td>
<td><stripes:textarea name="bugs[${loop.index}].shortDescription"/></td>
<td><stripes:textarea name="bugs[${loop.index}].longDescription"/></td>
</tr>
</c:forEach>
<c:choose> </table>
<c:when test="${actionBean != null}">
<c:set var="list" value="${actionBean.bugs}" scope="page"/>
</c:when>
<c:otherwise>
<c:set var="list" value="<%= new Object[5] %>" scope="page"/>
</c:otherwise>
</c:choose>

<div class="buttons">
<stripes:submit name="save" value="Save"/>
</div>
<c:forEach items="${list}" var="bug" varStatus="loop"> </stripes:form>
<tr>
<td>
${bug.id}
<stripes:hidden name="bugs[${loop.index}].id"/>
</td>
<td>
<stripes:select name="bugs[${loop.index}].component.id">
<stripes:option value="">Select One</stripes:option>
<stripes:options-collection collection="${componentManager.allComponents}"
label="name" value="id"/>
</stripes:select>
</td>
<td>
<stripes:select name="bugs[${loop.index}].owner.id">
<stripes:option value="">Select One</stripes:option>
<stripes:options-collection collection="${personManager.allPeople}"
label="username" value="id"/>
</stripes:select>
</td>
<td>
<stripes:select name="bugs[${loop.index}].priority">
<stripes:option value="">Select One</stripes:option>
<stripes:options-enumeration enum="net.sourceforge.stripes.examples.bugzooky.biz.Priority"/>
</stripes:select>
</td>
<td>
<stripes:select name="bugs[${loop.index}].status">
<stripes:option value="">Select One</stripes:option>
<stripes:options-enumeration enum="net.sourceforge.stripes.examples.bugzooky.biz.Status"/>
</stripes:select>
</td>
<td><stripes:textarea cols="25" rows="3" name="bugs[${loop.index}].shortDescription"/></td>
<td><stripes:textarea cols="25" rows="3" name="bugs[${loop.index}].longDescription"/></td>
</tr>
</c:forEach> </stripes:layout-component>
</table>
</stripes:layout-render>
<div class="buttons">
<stripes:submit name="SaveOrUpdate" value="Save"/>
</div>
</stripes:form>
<%@ include file="footer.jsp" %>
{code}

{code:title=MultiBugActionBean.java}
@UrlBinding("/bugzooky/MultiBug.action")
public class MultiBugActionBean extends BugzookyActionBean {
/** Populated during bulk add/edit operations. */
@ValidateNestedProperties({
@Validate(field="shortDescription", required=true, maxlength=75),
@Validate(field="longDescription", required=true, minlength=25),
@Validate(field="component.id", required=true),
@Validate(field="owner.id", required=true),
@Validate(field="priority", required=true)
})
private List<Bug> bugs = new ArrayList<Bug>();

public void setBugIds(int[] bugIds) { this.bugIds = bugIds; }

@ValidateNestedProperties({ /**
* Simple getter that returns the List of Bugs. Not the use of generics syntax - this is
* necessary to let Stripes know what type of object to create and insert into the list.
@Validate(field="shortDescription", required=true, maxlength=75), */
@Validate(field="longDescription", required=true, minlength=25),
@Validate(field="component.id", required=true),
@Validate(field="owner.id", required=true),
@Validate(field="status", required=true),
@Validate(field="priority", required=true)
})
public List<Bug> getBugs() {
return bugs;
}

/** Setter for the list of bugs. */
public void setBugs(List<Bug> bugs) {
this.bugs = bugs;

@DefaultHandler
@HandlesEvent("SaveOrUpdate")
public Resolution saveOrUpdate() {
BugManager bm = new BugManager();
PersonManager pm = new PersonManager();
ComponentManager cm = new ComponentManager();

for (Bug bug : bugs) {
}

return new ForwardResolution("/bugzooky/BugList.jsp"); RedirectResolution("/bugzooky/BugList.jsp");
}

@DontValidate
@HandlesEvent("PreEdit")
public Resolution preBulkEdit() {
// If the user didn't select any bugs to edit, bad user. if (this.bugIds == null) {
if (this.bugIds == null || this.bugIds.length < 1) {
ValidationErrors errors = new ValidationErrors(); getContext().getValidationErrors().addGlobalError(
errors.add( new SimpleError("You must select at least one bug to edit.") );
getContext().setValidationErrors(errors);
return getContext().getSourcePageResolution();
}
}

return new ForwardResolution("/bugzooky/BulkAddEditBugs.jsp"); RedirectResolution("/bugzooky/BulkAddEditBugs.jsp").flash(this);
}
}