Overriding a controls renderer - xpages

I'm having the following issue with the OpenNTF Bootstrap4XPages plugin: the NamePicker control uses a the Bootstrap renderer which displays it without the search field or the "add" field. I have raised this an issue on OpenNTF but in the meantime, I figured I would attempt to apply the ExtLib renderer for this control.
To date I have tried adding "com.ibm.xsp.extlib.OneUINamePicker" directly to the Renderer-Type property on the control (didn't work), added a renderer property set (taken from the ExtLib source) to the faces-config.xml (didn't work) both with theme enabled and disabled on the control.
So my questions are a) is this possible and b) if so, what am I doing wrong?

Thanks to Tim's comment, I had a moment of clarity in which I realised that I had been an idiot and had overcomplicated matters. I didn't need to worry about changing the renderer-type/adding a custom renderer. The simple answer was just to disable the theme for the NamePicker control which then forced it to use the ExtLib renderer anyway, giving me back the search button and both fields, albeit without styling.

The issue only occurred with the Bootstrap 3 themes. In the Bootstrap 2 themes, the correct renderer class was used.
I traced this down to a bug in the ExtLib theme file for Bootstrap 3. I've fixed it in the source code by setting the correct renderer class, so this will be solved in the next release.
See also: https://github.com/OpenNTF/Bootstrap4XPages/issues/59

Related

Using Bootsfaces Datatable- Not able to use dataTableColumn

I m using Bootsfaces0.9.1. When i try to use the bootsfaces datatable as suggested in showcase, i am not able to use b:dataTableColumn tag. It says that the "value" attribute is not defined in b:dataTableColumn tag.
<b:dataTable value="#{bookingAdminController.itemsBookDet}" var="items">
<b:dataTableColumn value="#{items.}"
</b:dataTable>
I am not able to access "items" in value attribute.
Actually, that's a bug (or feature) of Netbeans. The application works, but your IDE shows an error (or a warning). Either use BootsFaces-0.9.2-SNAPSHOT (see issue #369 on the BootsFaces GitHub repository to see how to get it), ignore the squiggly lines or use another IDE. You can also use the standard h:column tag, but in this case, the other attributes aren't supported by your IDE.
There's also a (solved) bug report on the BootsFaces bug tracker which addresses the problem.
Please note that the snapshot version is a developer preview. Don't use it in production.

prompttext in textfield of javafx 2 hides on focus after some java 7 update

i've been making simple javafx 2 gui application and found that prompttext in textfield of javafx 2 hides as soon as the textfield gets focus.
this wasn't this way some updates back.
prior to this update, the textfield showed the prompttext until some text is typed into.
this isn't good and really need a workaround for this.
I just solved this same issue by applying particular CSS rules to text inputs. Here's what I used (which should apply to all text-inputs)
.text-input, .text-input:focused { -fx-prompt-text-fill:darkgray; }
Erem Boto's answer is just fine and should solve your problem!
Please see my answer here to see how to solve the problem if you use proper Java code (no FXML and CSS file).
(And also how to get the other behavior back).
In short, this is the solution:
In case your application interface is written using proper Java code.
Java Code:
textField.setStyle("-fx-prompt-text-fill: derive(-fx-control-inner-background, -30%);");
Where textField is your TextField component.
And in case your application interface is written using FXML and CSS, add the following to your CSS file.
JavaFX FXML (CSS):
.text-input, .text-input:focused {
-fx-prompt-text-fill: derive(-fx-control-inner-background, -30%);
}

Setting JavaFX TreeView Line Style

In Java Swing, there is JTree.linestyle property that enables/disables lines connecting the parent nodes in a tree to their children. Is there something similar in JavaFX 2? In all of the TreeView examples I've looked at for JavaFX, I haven't seen this. I also didn't see a CSS property to set.
JavaFX 2.2 does not have such a setting out of the box.
A feature request could be filed in the JavaFX issue tracker.
You may be able to achieve the line connection effect by creating custom TreeCell and TreeItem nodes and, on those, setting the treeCell.disclosureNodeProperty and the TreeItem graphicProperty as appropriate based upon the various settable event handlers for the TreeItem.

Viewstate of UserControl failing to load after migrating 2.0 to 4.0

I have a gridview and a usercontrol. On Rowediting event i am binding details in usercontrol. But when any postback happens inside that usecontrol, then following excetion generates.
"Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request"
The code was working fine with framework version2.0. After migrating our website to framework version 4.0 this is not working
Note: I am not adding/replacing controls dynamically
This is resolved now. The problem was i was opening user control in row editing event and was not actually editing the row. i placed e.cancel=true; in row editing event which solved this issue

How to change the pictures related to links in JSF?

I have links and pictures related to these links on my page. I want to change the pictures everytime when onmouseover event occurred in the links. I want to do this in JSF.
A lot of Thanks to everyone.
You are looking specifically for JSF to do it, or you are open to other Javascript frameworks that provide a slick and easy solution on this? For example Jquery and Dojo etc may be easy to incorporate in your application and will give Rich UI effects.
On the other hand if you are looking at JSF specifically for these UI effects than probably I can try to think of some ways and let you know.
JSF isn't designed directly to do this; It's designed to give you the tools to do this yourself. In order to do this you would need to create a custom JSF component to do this and you would use Java script to do it.
You could possibly find a JSF framework that does this already (a4j, IceFaces, etc.) but this is such a simple and well documented JavaScript thing that just tossing a little Java script among your JSF is perfectly acceptable. However, if you don't want to reinvent the wheel, take a look at those other options.
Javascript solution:
Define onmouseover event on the commandLink tag calling some kind of javascript you may give link address from like onmouseover="doSomething('addressOfImage')" then in doSomething javascript method, first find the image, then set src attribute of a default image to given address.
JSF Solution:
You might want to use a4j for this.
Add a4j:support to link for onmouseover event then just rerender graphicImage component ofcourse you need to give value of graphicImage dynamically. There is an example of using a4j support below. You can add this a4j:support between your link tags for mouseonover event. Then manage everything on backing bean to handle which image to be displayed.
example
<h:graphicImage id="imageToBeRendered" value="#{myBean.imageAddress}"/>
Just google a4j if you have no idea.

Resources