use of org.olat.core.gui.control.Event in project openolat by klemens.
the class VelocityContainer method doDispatchRequest.
/**
* @see org.olat.core.gui.components.Component#dispatchRequest(org.olat.core.gui.UserRequest)
*/
@Override
protected void doDispatchRequest(UserRequest ureq) {
// called when a page-link is clicked ($r.renderCommand)
String commandString = ureq.getParameter(COMMAND_ID);
// WAS: set component dirty by default.
// if you are in ajax mode, and the link resulted in a external mediaresource, then you can (in your controller) manually reset dirty to false.
// we decided that there are only very few cases for this, and otherwise that the chance that a developers forgets to call vc.setDirty(true) is
// much higher
// now: normal links are created using the Link component, which takes care of setting dirty itself (everytime it is dispatched)
// setDirty(true);
// notify listening controllers
fireEvent(ureq, new Event(commandString));
}
use of org.olat.core.gui.control.Event in project openolat by klemens.
the class ValidatingVisitor method appendDispatchDebugInfos.
private void appendDispatchDebugInfos(Component target, StringBuilder debugMsg) {
Controller c = target.getLatestDispatchedController();
if (c != null) {
WindowControl wCo = null;
try {
wCo = c.getWindowControlForDebug();
} catch (Exception e) {
// getWindowControl throw an Assertion if wControl = null
}
if (wCo != null) {
String coInfo = "";
WindowControlInfo wci = wCo.getWindowControlInfo();
while (wci != null) {
String cName = wci.getControllerClassName();
coInfo = cName + ":" + coInfo;
wci = wci.getParentWindowControlInfo();
}
BusinessControl bc = wCo.getBusinessControl();
String businessPath = bc == null ? "n/a" : bc.getAsString();
String compName = target.getComponentName();
String msg = "wci:" + coInfo + "%%" + compName + "%%" + businessPath + "%%";
// allowed for debugging, dispatching is already over
Event ev = target.getAndClearLatestFiredEvent();
if (ev != null) {
msg += ev.getClass().getName() + ":" + ev.getCommand() + "%%";
}
String targetInfo = target.getExtendedDebugInfo();
msg += targetInfo + "%%";
debugMsg.append(msg).append(LOG_SEPARATOR);
} else {
// no windowcontrol -> ignore
}
}
// else: a component with -no- controller as listener, makes no sense in 99.99% of the cases; ignore in those rare cases
}
use of org.olat.core.gui.control.Event in project openolat by klemens.
the class RatingComponent method doDispatchRequest.
@Override
protected void doDispatchRequest(UserRequest ureq) {
setDirty(true);
String cmd = ureq.getParameter(VelocityContainer.COMMAND_ID);
try {
float rating = Float.parseFloat(cmd);
// update GUI
setCurrentRating(rating);
// notify listeners
Event event = new RatingEvent(rating);
fireEvent(ureq, event);
} catch (NumberFormatException e) {
log.error("Error while parsing rating value::" + cmd);
}
}
use of org.olat.core.gui.control.Event in project openolat by klemens.
the class GUIDemoMainController method handleOwnMenuTreeEvent.
@Override
protected Controller handleOwnMenuTreeEvent(Object uobject, final UserRequest ureq) {
if (uobject.equals("guidemo-autocompletion")) {
// for a demo of autocompletion, do a user search
ListProvider provider = new ListProvider() {
public void getResult(String searchValue, ListReceiver receiver) {
Map<String, String> userProperties = new HashMap<String, String>();
// We can only search in mandatory User-Properties due to problems
// with hibernate query with join and not existing rows
userProperties.put(UserConstants.FIRSTNAME, searchValue);
userProperties.put(UserConstants.LASTNAME, searchValue);
userProperties.put(UserConstants.EMAIL, searchValue);
List<Identity> res = BaseSecurityManager.getInstance().getVisibleIdentitiesByPowerSearch(searchValue, userProperties, false, null, null, null, null, null);
int maxEntries = 15;
boolean hasMore = false;
for (Iterator<Identity> it_res = res.iterator(); (hasMore = it_res.hasNext()) && maxEntries > 0; ) {
maxEntries--;
Identity ident = it_res.next();
User u = ident.getUser();
String key = ident.getKey().toString();
String displayKey = ident.getName();
String first = u.getProperty(UserConstants.FIRSTNAME, getLocale());
String last = u.getProperty(UserConstants.LASTNAME, getLocale());
String displayText = last + " " + first;
receiver.addEntry(key, displayKey, displayText, CSSHelper.CSS_CLASS_USER);
}
if (hasMore) {
receiver.addEntry("-1", ".....");
}
}
};
Controller c = new AutoCompleterController(ureq, getWindowControl(), provider, null, true, 60, 3, null);
// for demo only, normally use in parent controller
c.addControllerListener(new ControllerEventListener() {
public void dispatchEvent(UserRequest uureq, Controller source, Event event) {
EntriesChosenEvent ece = (EntriesChosenEvent) event;
String sel = ece.getEntries().toString();
getWindowControl().setInfo("selected entrie(s):" + sel);
}
});
return c;
}
return null;
}
use of org.olat.core.gui.control.Event in project openolat by klemens.
the class CPContentController method displayPage.
/**
* Displays the correct edit page when node with the given id is selected.
*
* @param ureq
* @param nodeID
*/
protected void displayPage(UserRequest ureq, String nodeID) {
CPManager cpMgm = CPManager.getInstance();
currentPage = new CPPage(nodeID, cp);
String filePath = cpMgm.getPageByItemId(cp, currentPage.getIdentifier());
logInfo("I display the page with id: " + currentPage.getIdentifier(), null);
VFSItem f = cp.getRootDir().resolve(filePath);
if (filePath == null) {
displayInfoPage();
} else if (f == null) {
displayNotFoundPage();
} else {
currentPage.setFile((VFSLeaf) f);
setContent(ureq, filePath);
}
fireEvent(ureq, new Event("Page loaded"));
}
Aggregations