I would like to know what is the prefered way to handle hour-minute input fields in JSF.
I am using JSF2.2 with primefaces 5.2
I would like to have one input field for hours and one for minutes and have the value saved to dabase in decimal and fraction format.
Then it would be nice alo so have a converter for this, for example if you have the need to store in minute or second precision. Is there already something availabe or do I realy have to write one of my own?
Related
Ideally I would like to apply Math.Round() method to my Blazor's InputNumber in order to remove the .xx from a decimal value.
<InputNumber class="someClass" #bind-Value="#DcValue"></InputNumber>
Please note the model's DcValue is decimal and will have to stay decimal.
Is there any way of doing this?
I ended up creating a custom control to manage that requirement. More details here.
i am new to JSF and i followed an online sample to take the edit data table as follows. May i know is this the good practice because i doubt that when the user the save the table, it will update every rows in the database thus it will causes the slow performance issue right?by the way, is JSF come with auto ajax? or it have to depend on jsf library like richfaces, primefaces and etc.
when the user the save the table, it will update every rows in the database
Instead of saving all the elements of the list, it's better to create another list with the elements that have been edited and then save the filtered list. This way you are only updating the edited elements, not all elements.
is JSF come with auto ajax?
You can add AJAX functionality to standard JSF components with the <f:ajax> tag. See http://www.jsftoolbox.com/documentation/help/12-TagReference/core/f_ajax.html.
This question already has answers here:
Convert and format a Date in JSP
(6 answers)
Closed 4 years ago.
I'm just starting using Spring and I'm quite new in this terms.
I'm having a problem, I need to convert one String to a Date in jsp, and I had thought to use jstl.
I know that the variable has a String which is: "17/03/2016" (I know It because without a format It displays ok)
I have tried all kind of things to be able of watching this String in format date but I have no idea why It's not working
${object.myattribute} <-- It displays correctly "17/03/2016"
But I need to have It on a date mode.
So I decided to try the fmt:formatDate option, but I must be doing something wrong 'cause I can't get the desired result. It even does nothing, and if the value is inside a table, It won't display the table.
I have tried many things but no one gives the correct result:
<fmt:formatDate type="both"
dateStyle="short" timeStyle="short"
value="${object.myattribute}" />
${object.myattribute}
<fmt:parseDate pattern="yyyy-MM-dd" value="${object.myattribute}" var="parsedStatusDate" />
${formattedStatusDate}
${parsedStatusDate}
This shows no result
<fmt:formatDate value='${object.myattribute}' pattern='dd/MM/yyyy' var="objMyAttrib" />
<c:set var="strDate" value="${object.myattribute}"/>
${strDate}
<c:out value="${strDate}"></c:out>
The problem is that no one result can be shown. I suposse that there must be some errors so I can't display this info.
I will continue trying but any idea will be really well received :) I assume that I'm doing something wrong but I can't figure what is what I'm doing wrong or if It can't be done (parse from String to Date in jsp)
Thank you in advance. An example will be also well received.
Try this :
<fmt:parseDate pattern="dd/MM/yyyy" value="${object.myattribute}" var="date" />
and use it like : ${date}
The problem was that I had to order a dataTable column by the string 25/06/2015 for example, and I need It on this style and no other.
But the dataTable was only ordering the column by the day.
As I read that I should pass a date from the controller, I found a solution that worked for me.
What I have done is to pass to the model another string which represents the date but in numeric form. I mean if I had "25/06/2015 " now I will have 20150625. dataTable will know how to order It correctly.
As I needed that "numeric String" to order the table I did something like this
<td>
// this one date is used to order the dataTable
p class="noVisible">${myObject.numericDate}/p//20150625
// this is the date that we will see in the table. It means that the dataTable will order the column by the first attribute It has in the td.
${myObject.stringDate} //25/06/2015
</td>
I hope this can help anyone who can have this kind of question ^^ even that is not a real solution It works for me
I have a simple document with 3 fields and 1 rich text field. I also have an xpage with 3 simple edit box controls and 1 rich text. The name of my NotesXSPDocument is document1.
Question 1:
Can i get a vector with all the controls of the xsp document? for example, instead of using getComponent("fld1"), getComponent("fld2") ... etc, can i use something like getAllComponents() or document1.getControls()? These methods do not exist of course so i am asking if there is a way to do it. I know i can get all items of a document (not XSP) by calling document1.getDocument().getItems(). IS there anything similar for xsp?
Question2:
Lets say we can get a vector as i described above. Then if i iterate through this vector to get each control's value, is there a method to check if it is rich text or simple text field?
Technically, yes, but not readily and this is one of those situations where there's likely a better way to approach whatever underlying problem it is you want to solve.
Nonetheless, if you're looking to get a list of inputs on the page, XspQuery is your friend: http://avatar.red-pill.mobi/tim/blog.nsf/d6plinks/TTRY-96R5ZT . With that, you could use "locateInputs" to get a List of all the inputs on the page, and then check their value method bindings to see if the string version is referencing your variable name. Error-prone and not pretty, but it'd work. Since they're property bindings, I don't think the startsWith filter in there would do what you want.
Alternatively, you could bind the components to something in a Java class from the start. I've been doing just such a thing recently (for a different end) and initially described it here: https://frostillic.us/f.nsf/posts/my-black-magic-for-the-day . The upshot is that, with the right cleverness for how you do your binding="" property, you could get a list of all the components that reference a property of a given object.
As for the second part of the question, if you DO get a handle on the components one way or another, you can check to see if it's a rich text control by doing "component instanceof com.ibm.xsp.UIInputRichText".
A bit complex but yes. facesContext.getViewRoot() is an UIViewRoot object so it has List<UIComponent> getChildren() method which returns its children.
However, since it's a tree-structure, some of its children will have additional children components. You have to traverse the entire tree to build a list of components you want to see.
For types, you can decide what type a component is by its class. For instance, UIInput is a text box, etc.
In my JSF2 application, I want my double value to be displayed without exponential notation. Is it possible?
I cannot use NumberFormat or DecimalFormat since its going to change my data type to String.
I understand from Java documentation, if my double value is less than 10^-3 or greater than or equal to 10^7, then it is represented in so-called "computerized scientific notation"(Ref: http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#toString()).
And, In JSF while displaying a double value it will internally convert any data type to string.
For example, if my double value is 9999999999 it is getting displayed as 9.9e^9. I want it to be displayed as it is. i.e 9999999999
But, it there any possibility to override this character of Double or is there any other approach to solve this issue?
The correct solution for problems like this is to pass the internal data type around for as long as possible. Just at the moment when you display it to the user, you format it properly using DecimalFormat.
So you have to find all the places in your JSF2 UI where you display doubles and use the proper formatters there.
Note that DecimalFormat isn't threat safe, so you have to create a new formatter for each request (at least).
If your code provides a double or Double, you can display that value directly in the page using a converter:
<h:outputText value="#{myBean.someDoubleValue}">
<f:convertNumber pattern="0"/>
</h:outputText>