I'm creating a fantastic HTML editor. I haven't thought about the title, so it's gonna be "HTML Editor." The input (in the code below) is to name the file. how could I name a file using the HTML's JavaScript components? Is there anything wrong with the code, or what?
<input id="title" required placeholder="File Name" title="Please fill this space up, and don't include symbols.">
<a download href="data:text/html;utf-8,(contents)"> <button>Download File</button> </a>
The downloading part is great and all, and I'm glad to say it's working, but... the name "download" is pretty irritating. Can you help me out here?
You need to set the download attribute to your filename.
<a download="filename.jpg" ... />
Related
We are currently converting a Spring mvc/jsp app into a jsf app.
Previously we could import the content of a JSP segment file into a text area like this
<textarea id="sectionSixPointOne" name="sectionSixPointOne">
<jsp:include page="sect_six_point_one.jspf"/>
</textarea>
Magically the content of the jsp appeared into the content of the text area.
We are trying to do the same with JSF, but I am about ready to shoot myself in the face.
We've tried
<h:inputTextarea id="sectionSixPointOne">
<ui:include src="section_six_sect_one.xhtml"/>
</h:inputTextarea>
But it includes the content after the textarea not inside it.
I have tried to include the content of as the value parameter of h:inputTextarea but the compiler gets it's knickers in a knot about the syntax/quotes/anglebrackets etc.
<h:inputTextarea id="sectionSixPointOne" value=<ui:include src="section_six_sect_one.xhtml"/>
</h:inputTextarea>
I would much rather include the content directly in the jsf pages rather than mucking about loading it into a backing bean.
Anyone got any ideas can what I want to do be done with jsf (apologies for any idiocy I am a total JSF newb?
Just put the <h:inputTextarea id="sectionSixPointOne"> with it's value to include in the file you want to include.
That way you don't need to insert it in some component, you just extracted the whole thing into its own file.
So you code looks like:
<ui:include src="section_six_sect_one.xhtml"/>
and in section_six_sect_one.xhtml":
<ui:composition xmlns=... >
<h:inputTextarea id="sectionSixPointOne" value="yourIncludedText"/>
...
I am stucked to something. In spring 2.5 framework, I want to upload file by using MultipartFile. I have a class called Dosya including property which is MultipartFile multiDosya. My command object is dosya. Additonally, The file which will be uploaded is stored BLOB type in database, sql developer,.
In jsp, I try to bind this propert like below:
<spring:bind path="dosya.multiDosya">
<input class="file" type="file" name="yuklenecekDosya" id="yuklenecekDosya" />
</spring:bind>
In onSubmit,
Dosya dosyaObjesi = (Dosya)command;
MultipartFile yuklenecekDosya = dosyaObjesi.getMultiDosya();
The commandObject dosyaObjesi is taken without problem, however,
dosyaObjesi.getMultiDosya()
value is coming null although file that will be uploaded is selected in jsp.
After searching on the net, I found that this line below should be added to the initBinder.
binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
However, my class says that there is no such class ByteArrayMultipartFileEditor, but it is available in spring-2.5.jar. I import
import org.springframework.web.multipart.*;
can trace out the problem . could someone please help me out
Thanks in advance.
Have you specified form encryption type(enctype="multipart/form-data")?. That could be the reason sometimes.
Ex:
<form method="post" name="formName" action="action.htm" commandName="object" enctype="multipart/form-data">
I have solved the problem. Everything is ok, however, in the code below
<input class="file" type="file" name="yuklenecekDosya" id="yuklenecekDosya" />
the attribute name must be ${status.expression} . That is, exactly, name="${status.expression}" like that. If only the name property value is given like that, bind operation works correctly.
Thanks,
Regards,
I am currently using Struts2 tags for my form, and to show its error messages. My question is that the default markup for showing error messages in Struts2 tags is the usage of <ul> tag. is there anyway I can change this? I want the error messages to be displayed as <span> not a list.
How would I achieve this?
Another option is to change the CSS for UL elements.
This approach works only if you specifically care about appearance, not the DOM itself.
You can override template files which are used for rendering errors. Copy actionerror.ftl and fielderror.ftl files from the simple theme from struts2-core jar to your application and modify them not to use ul/li tags.
The tags render according to their theme. The question then changes to: How do you change the theme? You can change it for the tag
(set theme attribute on the tag to simple), page, request, or generally.
http://struts.apache.org/2.2.1/docs/struts-2-themes.html
Personally I like writing html, that is I don't like any "help" from the struts2 default theme. So in my struts.xml I simply use:
<constant name="struts.ui.theme" value="simple" />
Web developers should know html.
Update:
Generally use YUI reset.css so I probably missed this...
If you extend ActionSupport on the action there is a getFieldErrors() method so you could use <s:property value='fieldError["field_name"]'/> that will return the associated error message string of course without any formatting.
It isn't much less readable than the <s:fielderror/> tag... after all we need to use property tags all the time anyways.
I had same issue I used following code to resolve my issue
<s:if test="fieldErrors.get('email').size() > 0">
<s:property value="fieldErrors.get('email').get(0)"/>
</s:if>
Where email is name of my field. This way we don't have to modify CSS.
Here is a tutorial to show the use of the Struts 2′s ActionError and ActionMessage class.
http://www.mkyong.com/struts2/struts-2-actionerror-actionmessage-example/
ActionError – is used to send error feedback message to user – display via < s:actionerror/ >
<s:if test="hasActionErrors()">
<div class="errors">
<s:actionerror/>
</div>
</s:if>
ActionMessage – is used to send information feedback message to user,display via < s:actionmessage/ >
<s:if test="hasActionMessages()">
<div class="welcome">
<s:actionmessage/>
</div>
</s:if>
In my web application (my first with Java, Spring, OR Roo), I'm building a form that has nothing to do with any JPA objects, it's just a form. I really don't want to use JSTL to build my forms here, because there's no data backing for them at this point. I'm using tiles to assemble the pages, so the guts of this form comes from a view, but apart from that there's nothing JSPish about it; it's just a form.
Inside that form, I have a text area that I've written:
<textarea id="whatever" name="whatever"></textarea>
When that comes to the screen, the </textarea> tag is gone. Different browsers deal with that differently, up to and including swallowing up the whole rest of the body HTML inside the text area field.
So I tried putting some content inside that textarea. Spaces and line breaks don't change its behavior, but it appears that any non-space character does. If I go
<textarea>.</textarea>
... it respects my close textarea tag. But then of course my text area renders on the screen with a dot in it, which isn't what I want.
Is this a known issue? Am I doing something wrong?
EDIT:
#bozho: Here's a pertinent chunk of my jsp:
<div id="notes" class="detailPanel">
<div class="panelLabel">Notes</div>
<table >
<thead><tr><th>Date</th><th>By</th><th>Note</th></tr></thead>
<tbody id="notesBody"></tbody>
</table>
<textarea id="newNote" rows="5" cols="80" >.</textarea>
<button id="addNewNote" onClick="saveNote();">Add New Note</button>
</div>
Absolutely nothing fancy going on here (I populate the tbody with rows on the client, is why that's empty). Without the dot in the third-to-last line, the closing textarea tag does not come out in the resulting HTML.
EDIT2 (Solution):
This URL became googlable after hearing some key words from people responding here:
http://www.jroller.com/komu/entry/textareas_with_jspx
Turns out that when jspx pages are parsed, empty tags are collapsed into a single self-closing tag, which breaks text areas. The solution is to put an empty jsp:text in the middle:
<textarea><jsp:text /></textarea>
(Which is STAGGERINGLY stupid, but there it is.)
You are using jspx files right?
In general jspx remove something (or in your case it shorten it: check this: I expect that it addes a slash to the former opening tag, so it becomes: <textarea id="whatever" name="whatever"/> ) where it belives that is not needed. What exactly depends ona bit on the implementation.
So put a <jsp:text> tag in the text area tag to prevent it from "closing"
<jsp:text>
<textarea id="whatever" name="whatever"></textarea>
</jsp:text>
<textarea id="whatever" name="whatever"><jsp:text /></textarea>
for an more complex example have a look at this answer: websphere 7 (and Spring Roo) incompatible with javax.el.ELException
I put a browser in my jsp page, and when I select the file via the browser
and I'm doing a System.outn select the file path, I only have the name,
and I need to recover all the file path selected
<form:form onsubmit="document.getElementById('idButton').value='Traîtement en cours ...'" action="ajouter.html"
method="POST">
<input type="file" name="cible">
<input type="submit" id="idButton" name="ajouter" value="Ajouter" tabindex="50"/>
</form:form>
(ActionForm)
String leChemin = (String) request.getParameter("cible");
System.out.println("leChemin = " + leChemin);
You cannot do this, for security reasons, file path from clients are not shown.
But if really need to get the path, do not rely on the browser use applet.
The path would be useless for you, none the less. Moreover, as a privacy concern, its not really a good idea to know the path at client's machine.