I have got input with date binding
<xf:bind nodeset="ns:date_1" relevant="true()" type="xs:date" />
and Orbeon creates inptut with datepicker, but it also requires me to fill it with date, otherwise it adds xforms-invalid css class.
How can I make it optional not required?
I've already tried adding attribute required="true()", but nothing happens.
I found it:
instead of
type="xs:date"
declare
type="xf:date"
Related
I've noticed that datepicker is reset to default value after the request has been done and the page reloaded.
Although I ensured that parameters are saved for use in pagination
...
<g:paginate total="${totalCount}" id="${params.id}"
params="[
startDate : params.startDate,
startDate_year : params.startDate_year,
startDate_month: params.startDate_month,
startDate_day : params.startDate_day]
/>
...
and it works as expected, the UI component itself shows default value. I'm afraid that it may irritate users. What should be done to make datepicker display the last value set by user and not the default one?
Your <g:paginate> tag is using the params appropriately, but your <g:datePicker> tag likely does not use a value attribute set to whatever was submitted.
I need to disable a select element in grails depending on its value. The problem is when I started to add the disable property something is quite wrong with the code.
An example is when the form is sent to the backend, its as if there is no value for that select element and the value sent is null. But, when I checked the DOM, there is a selected attribute in the element. I tried to remove that disabled property because I have a feeling that it has something to do with the bug that I'm encountering and I was right because after removing it, everything worked correctly again.
this is the select tag
<g:select name="detail-entryNameId"
value="${journalEntryName.savingId}"
from="${journalEntryNameInstanceList}"
optionKey="savingId"
optionValue="displayName"
readonly="${journalEntryInstance.paymentMade}"
/>
One more thing about this element is that it can occur as many as possible, which means I have a table and in every row, that element exist so I cannot simply manipulate it.
I've also read in this post how can i make a textfield read only in grails? that "If you use disabled="true" the value will not actually be submitted in the form, so the <g:field/> tag should be used." which proves that disable attribute affects the value of the element.
How can I disable the select element and at the same time, still get its value correctly?
The problem is that in HTML the mere existence of the disabled attribute disables the tag. The value of the attribute (true/false) is ignored.
In such cases the solution is to use an <g:if> to create the tag with or without the disabled attribute according to a condition.
In your case, since you want the value even when the tag is disabled you can add a <g:hiddenField> with the same name and value as the disabled select.
I am bound to remove a primefaces component only from client side. I am using jquery remove() for that.
As I can not set rendered=false from client side, so I am just trying to count or find in backend controller that the removed component is absent. After removing, I inspected the page html and the component is no more in dom. But before and after removing the component, I get the same value of child count (non zero) fetched through FacesContext:
FacesContext.getCurrentInstance().getViewRoot().findComponent("htmlGeneratedComponentId").getChildCount();
I know FacesContext won't know that the element has been removed by some client side script. JSF wouldn't know anything as no communication has been made to JSF and rendered attribute will remain true as checked by:
FacesContext.getCurrentInstance().getViewRoot().findComponent("htmlGeneratedComponentId").isRendered();
Right now, my requirement is that after removing a component using client side script I need to find in my java controller, a way to know that the component has been removed even if the rendered attribute is still true.
Pass that information via an additional request parameter which you could check in the rendered attribute of the component in question.
E.g.
<h:form>
<input type="hidden" id="fooRemovedByClient" name="fooRemovedByClient" />
...
<x:someComponent id="foo" rendered="#{not param.fooRemovedByClient}" />
</h:form>
And let jQuery set it accordingly on remove:
$foo.remove();
$("#fooRemovedByClient").val("true");
Needless to say that this is hacky. You'd better just let jQuery toggle the rendered attribute via a JSF/PrimeFaces ajax call. The <p:remoteCommand> is useful in this.
I have a selectOneMenu which is suposed to be processed when its value is changed.
The xhtml is quite generic so it's not very clear. Here it is:
<p:selectOneMenu
id="#{myId}"
value="#{obj[attr]}"
panelStyle="font-size: 10px;"
disabled="#{cc.attrs.grid.readonly}"
style="margin-top: 3px; width:79px;"
styleClass="#{change.getChangeClass(cc.attrs.grid)} toUpdate">
<f:selectItems value="#{cc.attrs.grid.valuesString}" var="elem" itemValue="#{elem}" itemLabel="#{elem}"/>
<f:validator validatorId="GenericValidator" />
<p:ajax
process="#this"
listener="#{rules.process()}"
update="#this"/>
Here is a part of the generated html which is clearer:
behaviors:{change:function(event){
PrimeFaces.ab({
source:'masterCenter:fuel3Content:j_idt621:fuel_codeCat',
event:'valueChange',
process:'masterCenter:fuel3Content:j_idt621:fuel_codeCat',
update:'masterCenter:fuel3Content:j_idt621:fuel_codeCat'}, arguments[1]);}
}
When I select a value, it gets posted (I can see with chrome tools that it is in the form data being posted).
But my validation method (GenericValidator.validate()) is not called.
When I submit the whole form, the validation method is called, but it indicates that the value of the combo is null.
I have the feeling that this value is not set as it should during the apply request values phase.
But this behaviour depends on the context:
This selectOneMenu is in a panel. The first time I open this panel (loaded with ajax), it works fine. I can change the value of the selectOneMenu and my validation method is called with the value that I've chosen.
Now when I open this panel again, the selectOneMenu doesn't work any more. However the generated html is exactly the same.
I also have the same behaviour with a p:inputTextarea in this form.
I'm using primefaces 3.4.1 with Mojarra 2.1.10. It looks to me like a primefaces/mojarra bug, but I haven't found notes of this problem.
in value expression value="#{obj[attr]}", why you are using a map? And how you set attr value? can you give more details?
In versions prior to jsf 2.0 validaton is ignored for empty and null fields. In jsf 2.0 if your jsf runs in environment where bean validation is supported then your empty or null fields are validated by default.
If you are using non j2ee 6 compliant servers like tomcat 6 or jetty in which bean validation is not supported then validation won't happen for null or empty fields.
If you want to enforce validation on empty fields you can use either required="true" or
<context-param>
<param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
<param-value>true</param-value>
</context-param>
Hope this helps. Leave a comment if you need further help
I have the following datepicker in a form
<g:datePicker name="born" default="none" precision="day"
noSelection="['':' ']" relativeYears="[-25..2]"
value="${animalInstance?.born}" />
Since I allow a no selection in the datepicker it's possible to enter a date with no days, no months but a valid year. It's exactly the intended behavior.
But the params come in the following format
born=""
born_year="1995"
Controller and Command object do not bind this correctly and the whole date is considered null.
Is there a proper way to handle this without doing some If...Then...Else code?