p:selectCheckboxMenu Dynamic CSS - css

I have populated multi select drop down list , i have a scenario like the color of the text in the dropdown should differ based on some condtions . i have populated the values in <f:selectItems>. I have attached the screen shot of the drop down by adding css to rendered html file. How could i add dynamic css for the label
xhtml :
<p:selectCheckboxMenu id="stackListDropDown" filter="true"
style="vertical-align:middle" filterMatchMode="contains"
value="#{stackListForPOCBean.selectedStackListFromDB}"
styleClass="help-inline selectOneMenuDefault">
<!-- <f:selectItem noSelectionOption="false" /> -->
<!-- <p:ajax event="change" process="#this"
listener="#{stackListForPOCBean.subjectSelectionChanged(stack)}" /> -->
<f:selectItems value="#{stackListForPOCBean.stackListFromDB}"
var="stack" itemLabel="#{stack.stackId} - #{stack.stackDesc}"
itemValue="#{stack.stackId}">
</f:selectItems>
<p:ajax update="stackLineGroup" process="#this "
listener="#{stackListForPOCBean.validateMultiSelectStackForPOC()}" />
<p:ajax event="toggleSelect" update="#this stackLineGroup"
listener="#{stackListForPOCBean.validateMultiSelectStackForPOC()}" />
</p:selectCheckboxMenu>
Expected Result using primefaces

I achieved it by the following code,changed to selectManyMenu and added checkbox true
<p:selectManyMenu id="stackListDropDown"
styleClass="help-inline selectOneMenuManyDefault"
value="#{stackListForPOCBean.stackListSelected}" var="t"
filter="true" filterMatchMode="contains" showCheckbox="true">
<f:selectItems value="#{stackListForPOCBean.stackListFromDB}"
var="stack" itemLabel="#{stack.stackId} - #{stack.stackDesc}"
itemValue="#{stack}" />
<p:column>
<h:outputText value="#{t.stackId} - #{t.stackDesc}"
styleClass="#{t.stackColorStyle}" />
</p:column>
<p:ajax update="stackLineGroup" process="#this "
listener="#{stackListForPOCBean.validateMultiSelectStackForPOC()}" />
</p:selectManyMenu>

Related

Hide default style class of p:selectOneRadio

I have used p:selectOneRadio in my xhtml page but I am not being able to remove their default style class .ui-helper-hidden-accessible, hence the radio button icons are not being visible.
My code is as follows:
<p:selectOneRadio
id="whetherRegisteredThroughEdistrictApp"
layout="grid" value="#{loginMBean.whetherCitizenUser}"
required="true" requiredMessage="#{i18n['errmsg-req-fields']}"
>
<f:selectItem itemLabel="Yes" itemValue="#{true}" />
<f:selectItem itemLabel="No" itemValue="#{false}" />
<p:ajax event="change" update="notcitizenUserDiv, citizenUserDiv" />
</p:selectOneRadio>
I think Javascript is the best way to do:
$( '#yourDivName input[type="radio"]' ).removeAttr( "disabled" );
or you can find with id end disable the disable attribute.
var radio = $('[id$=radio] input');
radio.attr('disabled','disabled');

Same space between 2 inputText boxes using JSF and CSS

I want to create a JSF form where users can write their name and surname and validate them using JSF validators. The problem is that I would like to set the same space between the 2 inputText boxes in the form, in both cases, when the typed data is correct according to the validator, and when it is not correct. So if between the 2 inputText boxes there are X pixels if the user has not typed anything, when typed name is not correct, the error showing message should be displayed between the 2 inputText boxes and the pixels between them should be also X px. I suppose this is a CSS issue, but I am unable to get it, so any help would be appreciated.
Here is my code
<h:form>
<p:panel id="panelregister">
<h:panelGrid columns="1">
<!--Name-->
<p:inputText id="name" label="name" size="32" maxlength="9"
value="#{mManagedBean.name}">
<f:validator validatorId="packagevalidators.NameValidator"/>
</p:inputText>
<p:watermark for="name" value="Name (*)" />
<p:message for="name"/>
<!--Surname-->
<p:inputText id="surname" label="surname" required="true" size="32" maxlength="9"
value="#{mManagedBean.surname}"
requiredMessage="Must enter a surname">
<f:validator validatorId="packagevalidators.SurnameValidator"/>
</p:inputText>
<p:watermark for="surname" value="Surname (*)" />
<p:message for="surname" />
<p:commandButton value="Submit" action="#{mManagedBean.save}" ajax="false" />
</h:panelGrid>
</p:panel>
</h:form>
You are using h:panelGrid which renders as HTML <table>.
p:message will be rendered as div and by default that div won't have any content so it won't take any space you provide.
One way to do this is to use a h:panelGroup around it and give pre defined height of p:message
Example:
<h:panelGroup layout="block" style="height:27px">
<p:message for="name" />
</h:panelGroup>

Scrollbar for outputLabel

I want to implment a scrollbar for a outputLabel but if i use scrollbar component it put every list elment in a new row. The whole output should be disyplayed in one row and the list should be scrollable. Can i fix this problem with a CSS attribute?
i use primefaces 4.0 and jsf 2.1
here is my code
<p:commandButton id="newMessage" update=":contentForm"
actionListener="#{taskboxBean.newMessage}" value="New Message" />
<p:commandButton id="trash"
update=":contentForm, :postForm:tabViewPosts:trashTable, :postForm:tabViewPosts:inboxTable, :postForm:tabViewPosts:sentTable"
actionListener="#{taskboxBean.deleteSelectedTaskbox}" icon="ui-icon-trash" title="Trash" />
<p:scrollPanel>
<ui:repeat var="task_to_user" value="#{taskboxBean.selectedTaskbox.TASKBOX_TO_USERS}">
<p:outputLabel
value="#{task_to_user.USER.EMAIL} #{task_to_user.USER.FIRST_NAME} #{task_to_user.USER.LAST_NAME} #{task_to_user.USER.FIRST_NAME}" />
</ui:repeat>
</p:scrollPanel>
<h:outputText value="#{taskboxBean.selectedTaskbox.TASKTYPE.NAME} " />
<h:outputText value="#{taskboxBean.selectedTaskbox.CREATE_TIMESTAMP} " />

Hide empty header of primefaces subtable

I have a set of subtables that is fed from the managed bean, and they may or may not have a header text.
<p:dataTable var="xxxxx" value="#{}" styleClass="xxxxx" emptyMessage="#{}">
<f:facet name="header">#{}</f:facet>
<p:columnGroup type="header">
<p:row>
<p:column headerText="xxxxx" />
</p:row>
</p:columnGroup>
<p:subTable var="xxxxx" value="#{}">
<f:facet name="header">
<h:outputText rendered="#{}"
value="#{}" />
</f:facet>
<p:column style="text-align:center;">
<h:outputText value="#{}" />
</p:column>
</p:column>
</p:subTable>
</p:dataTable>
Only structure shown. Tag contents wiped on purpose.
when the subtable header is empty text, it still renders a thin empty header line. Is there any way I can supress the exibition of that header in case empty?
Using PF 3.5 on Tomcat 7 (mojarra)
Supress the exibition of the empty header of the subtable by using this CSS property:
td.ui-datatable-subtable-header:empty {
display: none
}

insert markup into h:outputText to enhance some words jsf

I would like to insert a <span> into the value of this outputText :
<h:outputText id="jesuis1" value="la quantité nécéssaire : #{editCommandController.myCom.nbreExemplaire*editCommandController.myCom.nbrePage}" />
my goal is to enhance this {editCommandController.myCom.nbreExemplaire*editCommandController.myCom.nbrePage} by css but it generated an error
do you have any idea
You need the escape attribute!
<h:outputText escape="false" value="#any text including el that
evaluates to html tags"/>
or you could use
<h:outputFormat escape="true" value="text with {0} tags>
<f:param value="#{bean.htmlExpression}" />
</h:outputFormat>

Resources