JSF: selectOneListBox with checkboxes - jsf

Is it possible to create a selectOneListBox with checkboxes? And if so, how to do this or what would be the best approach? I do not want to do this using Primefaces, I only have license to Richfaces atm.
<h:selectOneListBox>
............
</h:selectOneListBox>
Thank you in advance.

Related

Is it possible to upload multiple files in simple mode in Primefaces FileUploader?

In the examples and showcase, fileUploadListener is always used in advance mode. I try to use it in simple mode but the uploadListener aren't called.
Is it valid?
<p:fileUpload multiple="true" fileUploadListener="#{formBean.handleFileUpload}" mode="simple"/>
Note: I already set ajax "false" and form enctype "multipart/form-data".
Kukeltje and Jaqen H'ghar are right. The answer is NO for Primefaces 5.2.

How to render different ui tags in a ui:repeat

I'm developing an application in JSF 2.0.
In the application there has to be a page where users can create document templates. It's comparable to the Google docs form feature. For example users should be able to determine where in the template they want an inputText, a textArea or a selectBooleanCheckbox. I designed a supersclass UiDocumentElement and the subclasses UiTextarea, UiInputText, ... .
Now I was wondering how I could display such a document template on my XHTML page. My backing bean will have a DataModel with UiDocumentElement objects. But how can I use a ui:repeat to display the different types of UI tags? Or should I try another design to achieve this?
Actually it comes to solving this problem:
<h1>#{backingBean.templateTitle}</h1>
<ui:repeat value="#{backingBean.uiDocumentElements}" var="uiElement">
<label>
<span>#{uiElement.label}</span>
<!-- here the application should know whether to render an inputText, an inputTextarea or a selectBooleanCheckbox with the attribute value="#{uiElement.value}" -->
</label>
</ui:repeat>
Any help would be greatly appreciated.
EDIT: see BalusC's comment with a link to a related question.
The easiest would be to have a 3-component block controlled through rendered attribute:
<h:inputText value="#{uiElement.value}" rendered="#{uiElement.type == 'input'}"/>
<h:inputTextarea value="#{uiElement.value}" rendered="#{uiElement.type == 'textArea'}"/>
<h:selectBooleanCheckbox value="#{uiElement.value}" rendered="#{uiElement.type == 'checkbox'}"/>

Drop down menu in primefacess

Using primefaces, how can i implement multiple selection of items in the dropdown list without using several dropdown menus...
is there tag in primefaces??
I think there's no primefaces component to achieve this but you can use plain jsf.
Try <h:selectManyMenu> or <h:selectManyListbox>.
Here is an example for the menu:
<h:selectManyMenu
id="newsletters"
value="#{bean.selectedItems}">
<f:selectItems
value="#{bean.availableItems}"/>
</h:selectManyMenu>
You'll find more information in the Java EE tutorial.
Primefaces 3.0 M1 has a SelectManyMenu component. You can download 3.0 M1 version here
2.2.1 doesn't have such component. Regards.

Primefaces Watermark on Rich Calendar

I am using JSF 1.2, Richfaces 3.3.1 and I am trying to display a watermark in <rich:calendar>.
I thought of using Watermark tag of primefaces <p:watermark> and so i have included primefaces1.1.jar in my classpath. It works fine for input text, but when i tried it on Calendar by using forElement of Watermark it didn't work.
Please find the below code snippet, where I used the generated client id in the forElement attribute.
<p:watermark forElement = "#includeId:GroupMasterForm:arrDateInputDate input" value="dd/mm/yyyy"/>
Is there any workaround for that? Thanks in advance.
Some suggestions:
I think the problem is that you try to combine two different component libraries. I am not sure if this works at all.
You could try to use p:calendar instead of rich:calendar in order to test if this is the cause.
Furthermore, I think your forElement content might be a reason. If calendar and watermark are siblings you can simply use the id of the calendar instead of the whole path.
Try this one:
<rich:calendar value="#{dataModel.date}" id="date"
datePattern="dd.MM.yyyy" enableManualInput="true"
showApplyButton="false" inputClass="watermark" required="true"/>
<p:watermark forElement=".watermark" value="TT.MM.JJJJ"/>
remember to define the p:watermark tag outside of rich:calendar

How do I reorder rows in DataTable using drag drop?

I am using PrimeFaces and JSF. Can anyone tell me how do I reorder rows of a DataTable using Primefaces drag and drop component?
Currently with in the PrimeFaces framework (v2.2.1 and 3.0) this is not possible with <p:dataTable>.
There is an open PrimeFaces Issue 511 <p:dataTable> draggable columns to add the Yahoo widget datatable draggableColumns attribute to the PrimeFaces <p:dataTable> but no target version is set yet.
If you would like to see this added to PrimeFaces star the issue to help give it higher priority.
This is definitely an older question, but the answer needs updating. This is now doable using the draggableColumns="true" attribute on your p:dataTable.
Your dataTable would then look as such :
<p:dataTable var="i" value="#{bean.data}" draggableColumns="true">
Sources :
PrimeFaces Showcase : DataTable - Columns Reordering
This feature is now available from PrimeFaces 5.0:
Usage is very simple by just enabling draggableRows option and also an optional rowReorder ajax behavior is provided getting a ReorderEvent with index information for flexibility.
Source : http://blog.primefaces.org/?p=3026
You can also have a look at the showcase here: http://www.primefaces.org/showcase/ui/data/datatable/reorder.xhtml

Resources