001/* 002 * JGrapes Event Driven Framework 003 * Copyright (C) 2017-2018 Michael N. Lipp 004 * 005 * This program is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Affero General Public License as published by 007 * the Free Software Foundation; either version 3 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, but 011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License 013 * for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License along 016 * with this program; if not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jgrapes.webconsole.base.events; 020 021import java.util.Set; 022import org.jgrapes.webconsole.base.Conlet.RenderMode; 023import org.jgrapes.webconsole.base.RenderSupport; 024 025/** 026 * Sent to the web console (server) if an existing web console component 027 * instance should be updated. The web console server usually responds with 028 * a {@link RenderConlet} event that has as payload the 029 * HTML that displays the web console component on the web console page. 030 * 031 * ![Event Sequence](RenderConletRequestSeq.svg) 032 * 033 * The event's result must be set to `true` by the rendering 034 * web console component. 035 * 036 * @startuml RenderConletRequestSeq.svg 037 * hide footbox 038 * 039 * Browser -> WebConsole: "renderConletRequest" 040 * activate WebConsole 041 * WebConsole -> Conlet: RenderConletRequest 042 * deactivate WebConsole 043 * activate Conlet 044 * Conlet -> WebConsole: RenderConlet 045 * deactivate Conlet 046 * activate WebConsole 047 * WebConsole -> Browser: "renderConlet" 048 * deactivate WebConsole 049 * 050 * @enduml 051 */ 052public class RenderConletRequest 053 extends RenderConletRequestBase<Boolean> { 054 055 private final String conletId; 056 057 /** 058 * Creates a new request. 059 * 060 * @param renderSupport the render support for generating the response 061 * @param conletId the web console component to be updated 062 * @param renderModes the render options 063 */ 064 public RenderConletRequest(RenderSupport renderSupport, 065 String conletId, Set<RenderMode> renderModes) { 066 super(renderSupport, renderModes); 067 this.conletId = conletId; 068 } 069 070 /** 071 * Returns the web console component id. 072 * 073 * @return the web console component id 074 */ 075 public String conletId() { 076 return conletId; 077 } 078 079 /** 080 * Checks if the web console component has been rendered (i.e. the 081 * event has been handled). 082 * 083 * @return true, if successful 084 */ 085 public boolean hasBeenRendered() { 086 return !currentResults().isEmpty() && currentResults().get(0); 087 } 088}