/** * Create a read only edit that contains the value of the selected file. It * can be placed anywhere in the DOM. * * @param sPlaceholder * The placeholder text to be used if no file is selected. * @return A node list with the edit and a JavaScript */ @Nonnull public HCNodeList createSelectedFileEdit (@Nullable final String sPlaceholder) { final HCEdit aEdit = new HCEdit ().setPlaceholder (sPlaceholder).setReadOnly (true); final HCScriptInline aScript = new HCScriptInline (JQuery.idRef (m_aEdit) .on ("change", new JSAnonymousFunction (JQuery.idRef (aEdit) .val (JSExpr.THIS.ref ("value"))))); return new HCNodeList ().addChildren (aEdit, aScript); } }
@Override protected void onFinalizeNodeState (@Nonnull final IHCConversionSettingsToNode aConversionSettings, @Nonnull final IHCHasChildrenMutable <?, ? super IHCNode> aTargetNode) { super.onFinalizeNodeState (aConversionSettings, aTargetNode); addClass (CBootstrapCSS.CUSTOM_FILE); final HCEditFile aEditFile = new HCEditFile (m_sName); aEditFile.addClass (CBootstrapCSS.CUSTOM_FILE_INPUT); addChild (aEditFile); final HCLabel aLabel = new HCLabel (); aLabel.setFor (aEditFile); aLabel.addClass (CBootstrapCSS.CUSTOM_FILE_LABEL); aLabel.addChild ("Choose file"); addChild (aLabel); aEditFile.addEventHandler (EJSEvent.CHANGE, false ? JSHtml.consoleLog (JSExpr.THIS.ref ("files").component0 ().ref ("name")) : JQuery.idRef (aLabel) .empty () .append (JSExpr.THIS.ref ("files").component0 ().ref ("name"))); } }
false ? JSHtml.consoleLog (JSExpr.THIS.ref ("files").component0 ().ref ("name")) : JQuery.idRef (aLabel) .empty ()