public JSLiteral getDragOptions(AbstractDragSource dragSource) { String options = dragSource.getDragOptions(); return !Strings.isNullOrEmpty(options) ? new JSLiteral(options) : JSLiteral.EMPTY_HASH; } }
private Object getMessageData(Message message) throws JMSException { Object messageData = null; if (message instanceof ObjectMessage) { messageData = ((ObjectMessage) message).getObject(); } else if (message instanceof TextMessage) { TextMessage textMessage = (TextMessage) message; if (message.getBooleanProperty(SERIALIZED_DATA_INDICATOR)) { messageData = new JSLiteral(textMessage.getText()); } else { messageData = textMessage.getText(); } } return messageData; } }
/** * Adds script which switches given panel to given item * * @param context FacesContext * @param itemName the item to switch to * @param panelId the panel */ protected void addOnCompleteParam(FacesContext context, String itemName, String panelId) { String script = new StringBuilder().append("RichFaces.$('").append(panelId).append("').onCompleteHandler('") .append(itemName).append("');").toString(); JavaScriptService scriptService = ServiceTracker.getService(JavaScriptService.class); scriptService.addScript(context, new JSLiteral(script.toString())); } }
/** * Adds script which switches given panel to given item * * @param context FacesContext * @param itemName the item to switch to * @param panelId the panel */ protected void addOnCompleteParam(FacesContext context, String itemName, String panelId) { String script = new StringBuilder().append("RichFaces.component('").append(panelId).append("').onCompleteHandler('") .append(itemName).append("');").toString(); JavaScriptService scriptService = ServiceTracker.getService(JavaScriptService.class); scriptService.addScript(context, new JSLiteral(script.toString())); } }
/** * This method ensures that component which should be focused will be present in the page in the time of running script (oncomplete). */ public void renderOncompleteScript(FacesContext context, String script) { JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class); javaScriptService.addScript(context, new JSLiteral(script)); }
/** * This method ensures that component which should be focused will be present in the page in the time of running script (oncomplete). */ public void renderOncompleteScript(FacesContext context, String script) { JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class); javaScriptService.addScript(context, new JSLiteral(script)); }
/** * This method ensures that component which should be focused will be present in the page in the time of running script (oncomplete). */ public void renderOncompleteScript(FacesContext context, String script) { JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class); javaScriptService.addScript(context, new JSLiteral(script)); }
javaScriptService.addPageReadyScript(context, new JSLiteral(String.format(SCRIPT, clientId)));
@Override public void focus(String componentId) { FacesContext context = FacesContext.getCurrentInstance(); if (context == null) { throw new IllegalStateException(FocusManager.class.getSimpleName() + " can't be used without FacesContext available"); } if (componentId == null) { setContextAttribute(context, null); } else { UIComponent currentComponent = UIComponent.getCurrentComponent(context); if (currentComponent == null) { currentComponent = context.getViewRoot(); } currentComponent.findComponent(componentId); UIComponent component = RendererUtils.getInstance().findComponentFor(currentComponent, componentId); if (component == null) { String message = FocusManager.class.getSimpleName() + ": Component with ID '" + componentId + "' was not found"; LOG.warn(message); context.addMessage(null, new FacesMessage(message)); } else { String clientId = component.getClientId(context); setContextAttribute(context, clientId); JavaScriptService javaScriptService = ServiceTracker.getService(context, JavaScriptService.class); javaScriptService.addPageReadyScript(context, new JSLiteral(String.format(SCRIPT, clientId))); } } }
@Override public void focus(String componentId) { FacesContext context = FacesContext.getCurrentInstance(); if (context == null) { throw new IllegalStateException(FocusManager.class.getSimpleName() + " can't be used without FacesContext available"); } if (componentId == null) { setContextAttribute(context, null); } else { UIComponent currentComponent = UIComponent.getCurrentComponent(context); if (currentComponent == null) { currentComponent = context.getViewRoot(); } currentComponent.findComponent(componentId); UIComponent component = RendererUtils.getInstance().findComponentFor(currentComponent, componentId); if (component == null) { String message = FocusManager.class.getSimpleName() + ": Component with ID '" + componentId + "' was not found"; LOG.warn(message); context.addMessage(null, new FacesMessage(message)); } else { String clientId = component.getClientId(context); setContextAttribute(context, clientId); JavaScriptService javaScriptService = ServiceTracker.getService(context, JavaScriptService.class); javaScriptService.addPageReadyScript(context, new JSLiteral(String.format(SCRIPT, clientId))); } } }
public JSFunctionDefinition getSubmitFunction(FacesContext facesContext, UIComponent component) { JSFunctionDefinition definition = new JSFunctionDefinition(JSReference.EVENT, new JSReference("element"), new JSReference("data")); AjaxFunction function = AjaxRendererUtils.buildAjaxFunction(facesContext, component); Map<String, Object> parameters = function.getOptions().getParameters(); parameters.put(component.getClientId(facesContext) + ":page", new JSLiteral("data.page")); definition.addToBody(function.toScript()); return definition; }
public JSFunctionDefinition getSubmitFunction(FacesContext facesContext, UIComponent component) { JSFunctionDefinition definition = new JSFunctionDefinition(JSReference.EVENT, new JSReference("element"), new JSReference("data")); AjaxFunction function = AjaxRendererUtils.buildAjaxFunction(facesContext, component); Map<String, Object> parameters = function.getOptions().getParameters(); parameters.put(component.getClientId(facesContext) + ":page", new JSLiteral("data.page")); definition.addToBody(function.toScript()); return definition; }