rich:editor disable convert_urls relative_urls on inserting image - jsf

I use rich editor(Seam, jsf) and here is my code:
<rich:editor value="#{bean.variableName}" height="280" width="400" theme="advanced" id="editor">
<f:param name="theme_advanced_buttons1" value="save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect"/>
<f:param name="theme_advanced_buttons2" value="cut,pasteword,copy,paste,pastetext,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor,hr,removeformat,visualaid,"/>
<f:param name="theme_advanced_toolbar_location" value="top"/>
<f:param name="theme_advanced_toolbar_align" value="left"/>
<f:param name="theme_advanced_statusbar_location" value="bottom"/>
<f:param name="theme_advanced_resizing" value="true"/>
<f:param name="language" value="#{locale.language}"/>
when I insert image from external url there is no problem,
but when I insert image from the same the host where the application is, the image url is converted(shortens)
from
<img src="https://myhost/path/my_image.png" />
to
<img src="../../my_image.png" />
I tried to find it out with options of rich:editor(http://livedemo.exadel.com/richfaces-demo/richfaces/editor.jsf?tab=info&cid=979762)
but it seems like there is no an appropriate option, also I found issue in stackoverflow Disable TinyMCE absolute to relative URL Conversions, but there is in js, unlike in my case, I tried to find where rich:editor takes the tinymce from, to edit there js file(if like so exists), but I couldn't find it. Help me please with these url conversion problem, thanks!

Related

Using JSF for <a href="myPicture.png" .../>

I have the following code:
<div id="links" class="links">
<ui:repeat var="storageAttachment"
value="#{gallerySlideshowController.selectedStorageAttachmentList}"
varStatus="status">
<a
href="https://farm9.static.flickr.com/8839/27742500683_1da5eca775_b.jpg"
title="Banana"> <p:graphicImage
title="#{storageAttachment.name}" cache="true"
value="#{galleryPictureThumbnailRequestController.pictureThumbnail}"
rendered="#{galleryPictureThumbnailRequestController.pictureThumbnail != null}">
<f:param name="id" value="#{storageAttachment.uniqueId}" />
</p:graphicImage>
</a>
</ui:repeat>
How can I replace the link in <a
href="https://farm9.static.flickr.com/8839/27742500683_1da5eca775_b.jpg" to my picture path?
I have stored the path on my local PC for every storageAttachment item. For example:
Object1: storageAttachment.path = C:/mypicture.png
So I need something like:
href="#{storageAttachment.path}"
-> But this is also not correct because I got http://C:/mypicture.png
How can I do this?
Thank you for every help.
Your PictureThumnailRequestcontroller.pictureThumbnail is StreamedContend, there are no href methods or getHref or anything like that but, you can get the image's InpuStream via pictureThumbnail.getStream(). I suppose what your trying to achieve is to render the image but bigger?
So maybe try a simple Servlet to render the image
Use Omnifaces to render with better ease.

JSF show icon without Button

I want to show the icons without buttons but it doesn't work. I get the following message: no Mime-Type was Found.
The two icons are default icons from Primefaces.
I use JSF 2.1 and primefaces 3.5
<h:graphicImage rendered="#{!task.IS_SEEN}" name="ui-icon-mail-closed"/>
<h:graphicImage rendered="#{task.IS_SEEN}" name="ui-icon-mail-closed"/>
If I use buttons it would work or can I set that the button can not be pressed
<p:commandButton rendered="#{!task.IS_SEEN}" icon="ui-icon-mail-closed" />
<p:commandButton rendered="#{task.IS_SEEN}" icon="ui-icon-mail-open" />
If you want just a clickable image that trigger an action in the backing bean I suggest wrapping a graphic image in a h:commandLink.
<h:commandLink rendered="#{!task.IS_SEEN}" value="" action="#{YourBean.myAction}">
<h:graphicImage value="your-image-here"/>
</h:commandLink>
If you want easy to use, nice, vectorial icons I suggest you to check Font Awesome http://fontawesome.io/icons/ as well.
To use Font Awesome just include the following line in your <h:head>:
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"></link>
Then you can easily put the icons inside commandLinks in this simple way:
<h:commandLink rendered="#{!task.IS_SEEN}" value="" action="#{YourBean.myAction}">
<i class="fa fa-envelope"></i>
</h:commandLink>
Also you need specify css class ui-icon like this:
<h:panelGroup styleClass="ui-icon ui-icon-mail-closed" />
those are in fact CSS classes that point to a sprite file, so technically they are not icons.
try using:
<h:panelGroup styleClass="ui-icon-mail-closed" rendered="#{!task.IS_SEEN}" />
and if there's a need style it accordingly with padding.

Showing HTTP addresses as links

I have a List of http addresses and I'd like to show them as links, so that people could click and go to the website.
I'm trying to do it like this, but it shows the http address, but not as a link:
Links Relacionados
<br />
<a4j:repeat value="#{pesquisaBean.selectedDocument.seeAlso}" var="uri" >
<h:link value="#{uri}" outcome="#{uri}" />
<br />
</a4j:repeat>
What's the problem?
The <h:link outcome> takes either a JSF navigation case outcome,
<h:link ... outcome="nextpage" />
or a JSF view ID,
<h:link ... outcome="/nextpage.xhtml" />
but definitely not an external URL, it would render as a <span> instead of an <a>.
<h:link ... outcome="http://stackoverflow.com" /> <!-- Fail. -->
This failure should also have been logged in server log. At least, Mojarra does that with a JSF1090 warning. Look once again at your server log:
WARNING: JSF1090: Navigation case not resolved for component j_idt7.
Use plain HTML <a> instead. You can specify the URL in its href attribute.
#{uri}

Button as link, <h:button outcome /> not working (no navigation cases used)

I am trying to achieve the following, though with a button.
<h:outputLink value="/admin/category/read">
Cancel
<f:param name="cat" value="" />
<f:param name="subcat" value="" />
</h:outputLink>
I have tried using h:button, though the outcome property does not work since /admin/category/read is not a specified navigation-case.
How to use a button as link, without having to use a navigation-case or server side method?
No, there's no solution using JSF attributes, at least not if you really don't have a navigation case for the h:button.
If possible, I'd advise to use CSS styling as already mentioned in the comments.
But h:button just creates a plain HTML link with onclick="window.location.href=URL". So if you really want, you can build the URL yourself and just use a plain HTML input button like this:
<input type="button" value="Cancel"
onclick="window.location.href='/admin/category/read?cat=&subcat='; return false;" />
Related:
Difference between h:button and h:commandButton
When should I use h:outputLink instead of h:commandLink?

JSF and links: the target property doesn't work?

I need to render a simple link in a page that open a pdf file in a new browser window.
I wrote the following tag:
<h:commandLink target="_blank"
action="showPDF"
title="Show attached PDF"
actionListener="#{bean.doShowPDF}"
value="Show PDF">
<f:attribute name="path" value="#{bean.pdfPath}" />
</h:commandLink>
The target attribute seems to be ignored. The destination page appear over the current.
I tried with h:outputLink:
<h:outputLink target="_blank"
title="Show attached PDF"
value="/visAttached.jspx">
<f:param name="path" value="#{bean.pdfPath}" />
Show PDF
</h:outputLink>
but with the same result. The generated html , in both cases, has not the target attribute.
Where's my fault?
There is a better strategy in JSF to show a file in a new browser window?
Try the ice: versions of them: ice:outputLink, or ice:commandLink. The component showcase shows a working example (layout panels/collapsible panels has a lot of links, check the source):
<ice:outputLink target="_blank" styleClass="navPnlClpsblLnks"
value="http://icefaces.org/main/home/index.jsp">
<ice:outputText id="icefacesOrgLink" value="ICEfaces.org"/>
</ice:outputLink>

Resources