Not sure if this was the right place to put this, but
it fit and was easy enough to fold in.
Have a series of pages with sub-forms that display one
record at a time, with navigation, so a user can
navigate through all of the sub-records associated with
the parent. It seems when you delete a record in this
configuration, it drops you into 'insert' mode instead
of going to the next record (or last) in the range of
records in the sub-form. In order to get this behavior
(as an option), I added the following attribute to the
DbFormTag:
Attr: navDeleteNext="true"/"false" - defaults to "false"
public class DbFormTag extends BodyTagSupport
implements TryCatchFinally
{
[...]
private String autoUpdate = "false";
/**
* if "true", delete events from the dbform will
generate a 'navnext' event after
* running the delete event.
*/
private String navDeleteNext = "false";
/** reference to a parent DBFormTag (if any) */
[...]
return maxRows;
}
/**
* Sets the navDeleteNext flag attribute of the
DbFormTag object.
*
* @param ndn The navDeleteNext value to set
(should be "true" or "false").
*/
public void setNavDeleteNext(String ndn)
{
navDeleteNext = ndn;
}
/**
* Returns the current value of the navDeleteNext
flag attribute.
*
* @return The current value of the navDeleteNext flag.
*/
public String getNavDeleteNext()
{
return navDeleteNext;
}
/**
* Gets the count attribute of the DbFormTag object
[...]
public int doStartTag()
{
try
{
[...]
request.setAttribute("webEvent",
webEvent);
}
}
// ...MGS...
// check to see if delete event and navnext
event needs to be generated
if ((webEvent != null) && (webEvent
instanceof DeleteEvent) && // is delete event
("true".equalsIgnoreCase(navDeleteNext)) &&
// want to goto next row
(request.getAttribute("errors") ==
null)) { // didnt have error...
logCat.info("Creating navNext event...");
webEvent = new
BoundedNavNextEventImpl(table, config);
}
// ...MGS...
if ((webEvent != null) && webEvent
instanceof NavigationEvent)
{
[...]
}
[...]
--- in dbforms.tld (after 'target' attribute)
<attribute>
<name>navDeleteNext</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
There may be a cleaner method for this and possibly a
better place, but this seems to work well for getting
to the next record after deleting.
Mike
Logged In: YES
user_id=496000
Whoops - the 'if' statement should be:
// ...MGS...
// check to see if delete event and navnext
event needs to be generated
if ((webEvent != null) && (webEvent instanceof
DeleteEvent) && // is delete event
("true".equalsIgnoreCase(navDeleteNext)) &&
// want to goto next row
((request.getAttribute("errors") == null) ||
// didnt have error...
(((Vector)
request.getAttribute("errors")).size() == 0))) {
logCat.info("Creating navNext event...");
webEvent = new
BoundedNavNextEventImpl(table, config);
}
// ...MGS...
- forgot that I added a check to see if an error had been
thrown in the delete event and the check for errors was wrong.