PrimeFaces calendar won't popup when used together with Tomahawk components - jsf

I have an application with a couple of Tomahawk components that I'd like to add a PrimeFaces calendar to. However, the PrimeFaces calendar won't popup unless I remove all the Tomahawk components. How is this caused and how can I solve it?
Edit- Here is part of the code I was talking about. I like the primefaces calendar time selector and want to use it, the tomahawk version is too clumsy. If I remove the tomahawk component the p:calendar works fine, but does not render when any tomahawk components are in my .xhtml (I use a tomahawk scheduler also that I didn't include here).
<h:outputLabel>Enter Appt Date:Time</h:outputLabel>
<t:inputDate popupCalendar="true" type="both" value="#{ScheduleMB.from}"/>
<p:calendar id="clientApptTime" value="#{ScheduleMB.datePrime}"
pattern="HH:mm" timeOnly="true" mode="popup" />
<h:outputLabel>Enter Appt. Length</h:outputLabel>
<h:selectOneMenu id="apptDuration" value="#{ScheduleMB.apptTime}">
<f:selectItem itemValue="45" itemLabel="45 minutes"/>
<f:selectItem itemValue="60" itemLabel="60 minutes"/>
<f:selectItem itemValue="90" itemLabel="90 minutes"/>
<f:selectItem itemValue="120" itemLabel="120 minutes"/>
</h:selectOneMenu>

Related

JSF Trinidad Rendering not working

I have a requirement, where selection of an item from one drop down, triggers the displays for another drop down. So i used a autosubmit on the 1st dropdown and valueChange Listener which set the flags for displaying the 2nd drop down.Thought the flag is set to true, the 2nd drop down is not getting rendered. Is this a right way to do, am i missing some thing here.
I am testing this in tomcat using trinidad 2.0.1 and JSF Core 2.0.2. Any help on this is highly appreciated
<h:form>
<tr:panelFormLayout labelWidth="30%">
<tr:selectOneChoice id="prior" value="#{render.priority}"
label="Priority" immediate="true" autoSubmit="true"
valueChangeListener="#{render.valueChanged}"
unselectedLabel="..Please select a priority">
<f:selectItem itemLabel="Low" itemValue="1" />
<f:selectItem itemLabel="Medium" itemValue="2" />
<f:selectItem itemLabel="High" itemValue="3" />
</tr:selectOneChoice>
</tr:panelFormLayout>
<tr:panelGroupLayout partialTriggers="prior"
rendered="#{render.displayInput}">
<tr:outputLabel value="Testing"></tr:outputLabel>
</tr:panelGroupLayout>
</h:form>
Is this your whole code? You would be missing some tags
<tr:document>
<tr:form>
........
</tr:form>
</tr:document>
////
<tr:form> instead of <h:form>

p:watermark clears on updating Component even if there is no value

I'm using Primefaces p:watermark on a p:inputText. Its working fine.
When ever I update the component its loosing watermark,even when there is no content inside the p:inputText
<h:form id="reg_frm">
<p:inputText id="name" value="#{user.name}"/>
<p:watermark value="your name" for="name" id="name_watermark" />
<p:selectOneMenu value="#{user.drpvalue}">
<f:selectItem itemLabel="One" itemValue="1"/>
<f:selectItem itemLabel="two" itemValue="2"/>
<f:selectItem itemLabel="three" itemValue="3"/>
<f:selectItem itemLabel="four" itemValue="4"/>
<p:ajax event="change" update="name name_watermark"/>
</p:selectOneMenu>
</h:form>
How do I retain the Watermark when there is no content in the
p:inputText after update?
Note: Primefaces version - 3.5
According to the PrimeFaces showcase for watermarks: "Watermark displays a hint about input fields by using native placeholder in supported browsers and a javascript solution in others browser compatibility."
PrimeFaces probably adds some hidden javascript stuff to the element which is a parent of both components (input and watermark). In your case that's the form which you would need to update. If you don't want that, put a new panelgroup around both elements and update that, which will have the same effect.
Try this attribute:
oncomplete="PrimeFaces.showWatermarks()"
It was given in Primefaces User's Guide.

Can i use immediate property in JSF to refresh my html page without calling any backing bean methods??

Can i use immediate property in JSF to refresh my html page without calling any backing bean methods?? i am new to jsf please suggest & also explain use of immediate
Imagine that you have this code:
<h:form>
<h:selectOneMenu id="subscriptions"
value="#{subscriptionController.subscriptions}"
immediate="true">
<f:selectItem id="item1" itemLabel="News" itemValue="1" />
<f:selectItem id="item2" itemLabel="Sports" itemValue="2" />
<f:selectItem id="item3" itemLabel="Music" itemValue="3" />
<f:selectItem id="item4" itemLabel="Java" itemValue="4" />
<f:selectItem id="item5" itemLabel="Web" itemValue="5" />
</h:selectOneMenu>
</h:form>
Regarding the immediate attribute is a boolean flag indicating that component events should be sent to registered event listeners immediately rather than after the validation phase of the JSF request processing lifecycle. The immediate flag allows you bypass JSF validation for a particular component. Reference here.
JSF life cycle is not easy to understand but you can check a good explanation here: JSF Life cycle
At a next level of experience you can add ajax to improve even more your performance. And the most recommended is to use libraries in that case, for example RichFaces and PrimeFaces.
Regards,
According to your requirement it seems that you don't need to use immediate attribute.
Just use f:ajax to process(execute) and update(render) particular elements or group of elements. It will not harm the performance.
And to know JSF Lifecycle and detail of immediate attribute please check Baluc's Blog
Use reRender attribute by using richfaces components for refresh the page or particular region of a page.

JSF SelectOneMenu Browser Back Button

I have a problem where I am using a SelectOneMenu for navigation:
<p:selectOneMenu value="#{navigator.outcome}">
<f:selectItem itemLabel="Select item.." />
<f:selectItems value="#{navigator.menuItems}" />
<p:ajax event="change" listener="#{navigator.navigate}" />
</p:selectOneMenu>
This works fine except when I navigate back it doesnt display "Select Item.."
The navigator bean is request scoped (I've tried view scoped as well).
I've disabled caching using a WebFilter.
You need to turn autocomplete off at the form level.
With JSF 2.1 you cannot do this.
Either wait until JSF 2.2 or uses omnifaces:
See link:
how to do autocomplete="off" at form level in JSF

noSelectionLabel in jsf?

There are many situations when we want to tell the user to select an option from a selectOneMenu component. In Seam this is easily solved using noSelectionLabel.
<h:selectOneMenu value="#{seasonHome.id}">
<s:selectItems value="#{seasonListQuery.resultList}"
var="season"
label="xxxSeason #{season.startYear}"
noSelectionLabel="Select Season"
hideNoSelectionLabel="true" />
<s:convertEntity />
</h:selectOneMenu>
Can you please tell me if there is something similar in JSF 1.2?
I'm using icefaces with a list for selectItems like:
<ice:selectOneMenu
id="#{id}"
required="#{required}"
styleClass="#{styleClass} #{not required ? 'graNotRequired':''}"
style="width: #{width};font-size: #{fontSize};"
partialSubmit="#{partialSubmit}"
disabled="#{disabled}"
value="#{fieldOneDataHolder[fieldTwo]}">
<f:selectItems value="#{selectableItems}" />
<f:validator validatorId="#{validatorId}" />
</ice:selectOneMenu>
(please ignore parameters, this is a custom component I made).
I can introduce a new <f:selectItem itemLabel="Please select" itemValue=""/> above f:selectItems but this is difficult (I have to find a way to hide it in some cases etc)...
Do you know other work-around?
Thanks.
<f:selectItem itemLabel="Please select" itemValue="" itemDisabled="true" rendered="#{isShown}" />
The itemDisabled will make it shown but not selectable.
The boolean in rendered will decide whether the item is shown or not.

Resources