Custom converter for textbox - xpages

Let me put the question in other words so, it may help remove it as a duplicate,
Is there a way to to use Xpages custom converter to display URL in text box as a hyperlink.

No, a converter converts data types... you would need a custom renderer to write out the needed anchor tags around your link.
What type of control are you using? If a <text> control (computed field) you can specify it as html for the content type and wrap your value you are getting from somewhere around the appropriate <a> tags.

Related

Custom Renderer - Add HTML tags

I've read a lot of posts about custom renderers, but I can't seem to find, what I am looking for.
It is, again, about the combobox. XPages renders the combobox in read mode as a table and the custom renderers I've found, help to write out just the value of the field.
What I would like to do though, is to wrap the value in HTML input tags, so that in read mode, the Bootstrap styles are applied to it.
Is it possible to do that in a custom renderer and if so, how would I do that?
Your help is greatly appreciated.
Wouldn't it be easier to just use a computed control when in read mode and have that control output the input tag you want? Hide the combobox in read mode and vice-versa?
Howard

How to edit the contents of a RichText field in Xpages using only a basic textarea

How do you disable the CkEditor for Rich Text fields so you only render a basic <texarea> tag with no editor whatsoever?
I'm sure I must be missing something obvious but I don't see to be able to create a document using an XPage with a field stored as RT without using the CkEditor. I want to be able to prompt the user to enter 'a lot' of text but only via a simple multiline input and have that stored as RT.
If I have a..
form with a RT field
an XPage with a xp:inputTextarea control bound to said field
a save button
a documentdatasource linked to that form
on save the document is created with the field value but it's stored as text rather than RT. Adding in computeWithForm to the dds properties doesn't help.
Is the only way to have some kind of querysave or custom converter to manually turn it into RT?
If I use the xp:inputRichText control it saves fine as RT but I don't want the CkEditor in the UI, just a basic . Is there a someway to do a editor=plain to the xp:inputRichText control?
I've been looking at trying to override the dojoType or renderType with no luck
Thanks!
You can use <xp:customConverter> in <xp:inputTextarea> to convert the text to rich text item.
For getAsObject you would write this code (document1 is your data source):
var rtitem:NotesRichTextItem = document1.getDocument().createRichTextItem("rtfield");
rtitem.appendText(value);
return null; // Return null as field has already been created
And for getAsString you would simply fetch the contents of rich text field and textual value.
value.getContentAsText()
The variable value is a standard variable which contains the actual value of the field. So you code for <xp:inputTextarea> would look something like this:
<xp:inputTextarea id="inputTextarea1" value="#{document1.rtfield}">
<xp:this.converter>
<xp:customConverter getAsString="#{javascript:value.getContentAsText()}">
<xp:this.getAsObject><![CDATA[#{javascript:var rtitem:NotesRichTextItem = document1.getDocument().createRichTextItem("rtfield");
rtitem.appendText(value);
return null;}]]></xp:this.getAsObject>
</xp:customConverter>
</xp:this.converter>
</xp:inputTextarea>
NOTE: If you wish to update the rich text field using the text area then you need to write additional code in getAsObject
I am not sure how to manipulate the field type. I assume that Domino know what is going on with the control in much the same way that the custom controls are formatted to match the content type. You might be able to force the content type.
I can present this as an alternative. You can do a custom toolbar in the ckeditor to remove the toolbar and make it appear like a normal text field. There may be UI complications with doing so though. You would also have a status bar to contend with to make it appear as a plain white box. There should be another dojo attribute type for this.
This code will give you a rich text box with no toolbar
<xp:inputRichText id="inputRichText1"
value="#{document1.content}">
<xp:this.dojoAttributes>
<xp:dojoAttribute name="toolbar">
<xp:this.value><![CDATA[#{javascript:var myToolbar = "[['']]";
return myToolbar}]]>
</xp:this.value>
</xp:dojoAttribute>
</xp:this.dojoAttributes>
</xp:inputRichText>

XPages disableOutput tag issue

Has anyone experienced an issue with disableOutputTag property where if you disable output tag for a computed field control inside a repeat control and have ssjs computed content inside that tag, it won't compute the content? Is disableOutputtag property only meant to work with static content inside a repeat control or is it a bug?
I don't know whether its a bug or not, but you can emulate the behavior of disableOutputTag by removing the ID attribute from and setting the disableTheme attribute to true. Maybe this helps you in short term.
EDIT: You can refer here for more information.
Not only does this happen when placing the xp:Text control inside a repeat but in also when you create a new XPage, add a xp:text onto it and define its value like:
<xp:text value="This is a test" disableOutputTag="true"/>
In the above example the xp:text will disappear. This is not what you would have expected. I would expect that only the value would be visible on the rendered page. But I think I can explain why this happens. Since there are no tags defined (disableoutputtag) somewhere in the rendered of this component it states that it should not generate anything. Because it can not bind its id to 'nothing' and so on.
Anyway, I could not think of a scenario where I would like to render plain text without any surrounding tags. It should at least be surrounded by a span or paragraph (<p>) tag so you can style it. And an ID would be nice so I can change the contents with a partial refresh.

XPages Rich Text Component

Is there any chance to get the html content (mime) from a rich text component without any datasource. I would like to grab the content from the field like this. getComponent("FieldName").value but this dosen't work.
thanks.
You can bind the control to a scoped variable; for example, #{viewScope.comments}. You can then retrieve the submitted value from the scope instead of from the component itself; for example, viewScope.get("comments").
Alternatively, you can set a dataContext variable to a JS expression, e.g. <dataContext var="richText" value="#{javascript:return {value:""};}" />. Then you can bind the control to #{richText.value} and retrieve it via the same expression.
And, of course, you could define a managed bean and bind the control to one of its properties. This option provides the most flexibility, but isn't quite as simple as the other two options above.
The solution for my problem is
getComponent("FieldName").getValue()
thanks for your help.

jsf popupwindow with a datatable

I have a form which one of it's fields is a code and description, also a button for opening a popup window that contains a list of all of the available codes.
when the user double clickes a row from that table i want to set these values to the code and description. - how can this be done?
Another question, I want to create this popup and table to be initialized dynamically - by that i mean that if i have a few forms in my application, when ever i have a field which has a description i want to be able to open this popup and to see the available list for that field. (every field can be from a diffrent table). is it possible to create something like that? if so, how?
Any help will be appritiated,
Thank's In Advance.
Yes, it is possible. Even more, many component libraries have ready to use popup/dialog components, such as RichFaces with <rich:popupPanel> and PrimeFaces with <p:dialog>.
If you do not want to use a component library for some reason, you would need to create a custom component for this which generates basically an absolutely positioned HTML <div> element with a CSS overlay which get shown/hidden by JS on a particular click/action. The HTML/CSS/JS part should be relatively simple if you are familiar with those languages. The JSF part is somewhat hard if you have never created a custom component before, but it should be possible with a composite component as well, so you could also just create one with pure XHTML. The updating/refreshing can just take place by the usual <f:ajax> means.

Resources