i have a DbForm page that will render an associated radio button for certain records depending on a flag column for each record.
i use this radio button to allow the user to update/delete those records only. so the user must select one of these records before pressing the update/delete button. (records that don't have an associated radio button means it cannot be modified or deleted)
on certain pages (using pagination), all the displayed records will not be updatable/deletable. on other pages, the first record will not be updatable/deletable. however, in both cases if the user presses update/delete it generates a null exception because the KeyInfo object required for creating an Event object is null (because there is no record selected and therefore no key).
the code for DbAssociatedRadioTag assumes there is always a first row associated radio button for putting the default "checked" attribute:
if (getParentForm().getCurrentCount() == 0)
{
tagBuf.append(" checked=\"true\"");
}
but this is not always true in my case.
and because KeyInfo is null, it will throw an exception in the createEvent() function of the DatabaseEventFactoryImpl class here:
constructorArgs = new Object[] {
new Integer(kInfo.getTableId()),
kInfo.getKeyId(),
request,
config
};
unfortunately, this error happens very early. and i cannot use interceptors or even validation to make a workaround. it seems that a modification of the Controller class, and/or the DatabaseEventFactoryImpl is the only way to stop the creation of Event objects (which depend on KeyInfo) when the creation of KeyInfo is not possible.
any thoughts about this?
thanks in advance,
woodchuck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i'm trying to fix the code in the DatabaseEventFactoryImpl class but i'm stuck.
i decided to simply 'refresh/reload' the current page when this situation occurs (ie. when KeyInfo is null). so i did the following in the affected part of the createEvent() function:
however, the problem is i can't figure out how to keep DbForms from going to the next page of data results. that is, it seems to function like the "Next" (pagination) button now.
how do i create a 'reload/refresh' event that will keep the user on their current pagination page?
thanks in advance!
woodchuck
p.s. i am working on 1.14 rev of the DatabaseEventFactoryImpl class... i checked and this is the same as the 1.15 rev... i don't know why there is a different rev number but the code is the same...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i thought i could trick the DbFormTag logic by setting the "lastpos_" parameter to equal the "firstpos_" parameter but the request parameters are immutable.
is there some other easier way to reload the page and keep the same pagination position?
thanks in advance!
woodchuck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i noticed that the change works but it does not preserve any current form data... it reloads data from the database. so any form data modifications are lost.
to fix this, and have the reload preserve the posted data, just comment out the line (or omit completely):
event.setType(EventType.EVENT_NAVIGATION_RELOAD);
i think this would be better.
thanks,
woodchuck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hihi Henner,
i have a DbForm page that will render an associated radio button for certain records depending on a flag column for each record.
i use this radio button to allow the user to update/delete those records only. so the user must select one of these records before pressing the update/delete button. (records that don't have an associated radio button means it cannot be modified or deleted)
on certain pages (using pagination), all the displayed records will not be updatable/deletable. on other pages, the first record will not be updatable/deletable. however, in both cases if the user presses update/delete it generates a null exception because the KeyInfo object required for creating an Event object is null (because there is no record selected and therefore no key).
the code for DbAssociatedRadioTag assumes there is always a first row associated radio button for putting the default "checked" attribute:
if (getParentForm().getCurrentCount() == 0)
{
tagBuf.append(" checked=\"true\"");
}
but this is not always true in my case.
and because KeyInfo is null, it will throw an exception in the createEvent() function of the DatabaseEventFactoryImpl class here:
constructorArgs = new Object[] {
new Integer(kInfo.getTableId()),
kInfo.getKeyId(),
request,
config
};
unfortunately, this error happens very early. and i cannot use interceptors or even validation to make a workaround. it seems that a modification of the Controller class, and/or the DatabaseEventFactoryImpl is the only way to stop the creation of Event objects (which depend on KeyInfo) when the creation of KeyInfo is not possible.
any thoughts about this?
thanks in advance,
woodchuck
You are right,
Can you fix it and send me the changes?
Thanks
Henner
hihi Henner,
i'm trying to fix the code in the DatabaseEventFactoryImpl class but i'm stuck.
i decided to simply 'refresh/reload' the current page when this situation occurs (ie. when KeyInfo is null). so i did the following in the affected part of the createEvent() function:
if(null == kInfo)
{
EventInfo reloadEventInfo = new EventInfo(EventType.EVENT_NAVIGATION_RELOAD, ReloadEvent.class.getName());
int tableId = StringUtil.getEmbeddedStringAsInteger(action, 2, '_');
constructorArgs = new Object[] {
config.getTable(tableId),
request,
config
};
event = getEvent(reloadEventInfo,
new Class[] {
Table.class,
HttpServletRequest.class,
DbFormsConfig.class
},
constructorArgs);
}
else
{
// args are: tableId, keyId, request, config
constructorArgs = new Object[] {
new Integer(kInfo.getTableId()),
kInfo.getKeyId(),
request,
config
};
event = getEvent(einfo, keyInfoConstructorArgsTypes, constructorArgs);
}
however, the problem is i can't figure out how to keep DbForms from going to the next page of data results. that is, it seems to function like the "Next" (pagination) button now.
how do i create a 'reload/refresh' event that will keep the user on their current pagination page?
thanks in advance!
woodchuck
p.s. i am working on 1.14 rev of the DatabaseEventFactoryImpl class... i checked and this is the same as the 1.15 rev... i don't know why there is a different rev number but the code is the same...
i thought i could trick the DbFormTag logic by setting the "lastpos_" parameter to equal the "firstpos_" parameter but the request parameters are immutable.
is there some other easier way to reload the page and keep the same pagination position?
thanks in advance!
woodchuck
1. You can add an attribute lastpos_ to the request. This will superside the parameter
2.What's happen if you return null instead of an event?
3. What's happen if you return a noop event ?
Henner
hihi Henner,
1) ok i can try this.
2) if i return null, then the page after processing is completely blank, lol!
3) i saw the Noop event object but didn't know what it does so i didn't use it. i will try this if #1 does not work.
thanks!
woodchuck
i'm trying to add the parameter but it throws an IllegalStateException:
request.getParameterMap().put("lastpos_"+tableId, "test");
am i doing this correctly?
woodchuck
hihi Henner,
the Noop event is funny, it brings me back to the very first pagination page.
but, i tried the PageReloadEvent and it works beautifully, it keeps the user on the same current page. this is perfect!
here is the working code:
if(null == kInfo)
{
int tableId = StringUtil.getEmbeddedStringAsInteger(action, 2, '_');
event = new PageReloadEvent(tableId, request, config);
event.setType(EventType.EVENT_NAVIGATION_RELOAD);
}
else
{
// args are: tableId, keyId, request, config
constructorArgs = new Object[] {
new Integer(kInfo.getTableId()),
kInfo.getKeyId(),
request,
config
};
event = getEvent(einfo, keyInfoConstructorArgsTypes, constructorArgs);
}
let me know if you want me to e-mail the entire .java file to you. the above is all i changed.
thanks!
woodchuck
Just inserted this into the CVS sources and run a test build.
No errors - so it seems not to break the tests.
So it will be in the next build
Henner
hihi Henner,
i noticed that the change works but it does not preserve any current form data... it reloads data from the database. so any form data modifications are lost.
to fix this, and have the reload preserve the posted data, just comment out the line (or omit completely):
event.setType(EventType.EVENT_NAVIGATION_RELOAD);
i think this would be better.
thanks,
woodchuck
Ok, i just commited it. Could you test again?
Henner
hihi Henner,
i still don't see your changes (i'm browsing cvs using the web so maybe the changes have not been updated to the web yet).
but i have already tested here before and it's working well. without the line:
event.setType(EventType.EVENT_NAVIGATION_RELOAD);
DbForms will preserve all posted data on the form.
thanks,
woodchuck