Primefaces Watermark on Rich Calendar - jsf

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

Related

bootsfaces b:commandButton in ui:repeat not updating h:graphicImage

I'm using the 0.7 version of bootsfaces to create a simple page, which has something like the following:
<h:form id="some_form">
<ui:repeat id="some_elements" var="property" value="#{someBean.properties}">
<b:commandButton value="ShowProp" ajax="true" actionListener="#{someBean.showProperty(property)}" update=":some_form:some_elements:graphic"/>
<!-- This property is true -->
<ui:fragment rendered="#{someOtherBean.showGraphic}">
<h:graphicImage url="gen_image?id=#{property.id}" id="graphic"/>
</ui:fragment>
</ui:repeat>
</h:form>
Now, the idea is that on clicking the button, a property is updated and the image should be re-generated (in this case a jfreechart graph - but this is besides the point.) I tested this with primefaces commandButton and it works fine (the graph is redrawn..) However with bootsfaces commandButton, nothing happens once the ajax call completes (I can see the call on the server side, but the graph is not reloaded.) I think it's down to how it must reference the image in the repeated block, but now sure what is wrong - has anyone come across this?
(NOTE: reason I don't want to use primefaces is that it does not integrate well with bootstrap)
I've opened a bug on the project's bugtracker (https://github.com/TheCoder4eu/BootsFaces-OSP/issues/135).
Actually, why did you expect the update=":some_form:some_elements:graphic" to work in the first place? This expression is an id that doesn't exist. The id is some_form:some_elements:0:graphic. In other words: it contains the row number. PrimeFaces (and Mojarra and MyFaces) recognizes that the command button is part of a UIRepeat group and guesses the correct row number. But that's just a guess. Obviously a reasonable guess, because most of the time you want to update something that's in the vicinity of the command button.
The next version of BootsFaces is going to guess the correct row number, too :).

How to call bean method when drag-drop the element using <p:pickList>?

I am using primefaces 3.3 library for jsf based application.
I am using <p:pickList> to handle drag and drop the element from source to target and vide versa.
I want to call the jsf bean method when element transferring(by drag-drop ) from source to target and vice versa and handle some logical things there.
I follow the link PrimeFaces showcase for pickList to implement my functionality. This is the version 5.2.7.
In primefaces 5.2.7 it can be easily done by <p:ajax event="transfer" /> , but how can I achieve this using primafaces 3.3.
I try valueChangeListener attribute but it is not working.
There is one attribute called onTransfer , but it is for clientSide callback.
This can be achieve by putting submit button. But I want to achieve it on drag and drop. So how can i do that ?
Thanks in advance.
First, you should consider an update of your primefaces version. Updates are not only provided for new features but also for bug fixes, improvements (performance, stability) etc.
Currently I cannot find the documentation for 3.3, but what you could try is using p:remoteCommand (its in the 3.5 documentation, so maybe available):
use onTransfer="submitToBean()" along with a p:remoteCommand that might look like this:
<p:remoteCommand
name="submitToBean"
action="#{myBean.doSomething}"
process="idOfYourPickList"
partialSubmit="true" />
Then the onTransfer Event will call the javascript method submitToBean() which in turn will process your picklist and call the action method.

Seam conditional render without parsing

I'm trying to make a conditional render in my Seam application (2.2.0), to display two different controls depending on a condition.
I'm using the s:fragment tag with the render attribute, but my problem is that I want whatever the control is displayed, to have the same id:
<s:fragment render="${editable}">
<rich:calendar id="entityDate"..../>
</s:fragment>
<s:fragment render="${!editable}">
<h:outputText id="entityDate".../>
</s:fragment>
My problem is that even when the render attribute set to false, the "not to be rendered" element is parsed, and I get an exception because of the duplicated id.
I also tried with the tag <ui:remove>, which effectively removes the element before the parsing phase, so I can have something like:
<span id="myId"/>
<ui:remove>
<span id="myId"/>
</ui:remove>
Unfortunately the <ui:remove> tag doesn't allow conditional logic. Has anyone found a way to solve this?
That's only possible when you use a view build time tag such as JSTL <c:if>.
<c:if test="#{editable}">
<rich:calendar id="entityDate" />
</c:if>
<c:if test="#{!editable}">
<h:outputText id="entityDate" />
</c:if>
(note that this is not going to work within an iterablte JSF component, such as <ui:repeat>, <h:dataTable> and so on)
After all, I strongly recommend to take benefit of the disabled attribute instead, if necessary with a good shot of CSS to hide the input field borders and so on. It'll minimize the JSF view boilerplate code.
<rich:calendar id="entityDate" disabled="#{!editable}" />
Disabled inputs are separately styleable by the CSS attribute selector element[attribute], e.g.
input[disabled] {
border: 0;
}
The above removes the border of input elements with the disabled attribute present so that it look like a normal output text.
"Solve"? There is nothing to solve here: two elements in a GUI can not have the same ID. Hardly unnatural or unsound?
It's like asking: "I have a database table with two rows, I would like them both to have the same primary key value, but somehow I get these errors... has anyone managed to solve the problem and circumvent the constraints?".
Or even closer analogy: "I have two spans, one of them is invisible (has style="display: none") I would like them both to have the same id - and browsers seem not to like it, despite one of the spans being invisible".
Bottom line: rendered on not rendered, each component is still a part of the view tree, and therefore has a UNIQUE id.
I have a suspicion that you want to have some "polymorphic" code that should work with the currently visible element. Using ID for such code IS WRONG. If you show us your use case, we might find a right way to achieve the effect.
I use selenuim myself in a seam environement and i recommend using defined ids whenever possible. First you have the ability to create smaller ids which is usefull for pagesize. Second the selenium test run alot faster if you use ids for referencing instead of other selectors. I have not yet found a selenium test where you cannot handle diffrent ids. Additionally if a code fails in jsf tree creation you see which id is failing.
I see you are using sfragment with editable or not. I use the sdecorate and give the decorate an id and then "just" ed for the input and vi for the outputtext for example. This makes it easy in selenium to check the availability of edit or view components.
Would you be able to get the same results you need by putting the id tag on the fragment?
So:
<s:fragment id="entityDate">
<rich:calendar render="${editable}" />
<h:outputText render="${!editable}" />
</s:fragment>

a4j:support tag not found using JSF 2

just trying to integrate this commandLink
<a4j:commandLink reRender="results-view" actionListener="#{myaction}" oncomplete="return false;" value="#{msg1.advanced_search}">
<a4j:support event="onclick">
<f:setPropertyActionListener value="./page.xhtml" target="#{changeViews['new-view'].value}" />
</a4j:support>
</a4j:commandLink>
On an applicacion which is using JSF2. If I leave it, I get this error
Tag Library supports
namespace: http://richfaces.org/a4j,
but no tag was defined for name:
support
I was trying to find something on the net, but I couldn't figure out. Some help would be great.
Thanks in advance
The a4j:support has been replaced by a4j:ajax since RichFaces 4.x.
You seem to be reading RichFaces 3.x documentation or just have upgraded RichFaces 3.x to 4.x. This is a pretty major step where a lot of things are been changed. Read the migration guide (in this particular case, it's described in a4j components) and also read the new RF4 component reference.

i have two text box in two different pages a

i have two text box in two different pages and same variable use in two text box when enter value in first text box it's reflection show in second text box , how i reduce it in jsf ?
You can create a #SessionScoped bean named GeneralBean
Set a variable there e.g.:
private String name;
add getters and setters.
In the pages where the user enters his data you should have
<h:form>
<h:inputText value="#{generalBean.getName}">
<f:ajax event="change" />
</h:inputText>
</h:form>
Using Ajax, whenever he changes the value it will affect the name variable which appears also in the other screen.
EDITED:
I presumed that you are using JSF2.0. If not, please indicate it.
EDITED:
Since you are using JSF1.1 you will need external tool support.
You can use RichFaces a4j:support.
For that you need to download richfaces.
Use a4j:support. See an example here:
a4j:support
EDITED:
This answer is if the pages are not opened simultaneously.If they are opened at the same time you will have to use richfaces push optionin the other one.

Resources