I would like to render a group of name-value only if a value is not null (or another condition). This group of name is among other names and values which are always rendered.
To format the page, I use a <h:panelGrid columns="2">.
If I use a <h:panelGroup rendered='thecondition'> the alignment does not work. I tried <ui:fragment> and it didn't work either.
The group contains a large number of values and I would like not to add a rendered attribute for each name and each value of the group. Is there another solution?
Related
I would like to display a list of information per entry in the table. For example for each user, one can have multiple cell phone numbers.
The users are listed in the and I have an for the cell numbers. I would like to loop through the list of numbers per user and list them in the column for the cell phone numbers.
I have tried to add the ui:repeat in the in the following way:
<ui:repeat value="#{user.cellNumbers}" var="cellNumber">
and the table holds the user array in the following manner:
<af:table id="t1-rapb" value="#{userBean.users}" var="user">
I expected the ui:repeat to iterate through the list of numbers per user, but instead nothing appears in that column. What am I missing in order to make this work?
I would like to swap two columns in JSF h:dataTable based on a condition. For instance if a user chooses red, then the column with red values comes first. If he chooses the other color say blue then the column with blue values comes first and the other afterwards.
I have played with the rendered attribute but it is not working.
If you use Primefaces you can bind the columns to a collection in the server side, so you can filter and rearrange columns as you like
Example:
https://www.primefaces.org/showcase/ui/data/datatable/columns.xhtml
With plain JSF I don't think that's possible, but you could go with a client approach such reordering the <td> elements with jQuery.
I'm working on a small Project using Primefaces.
I'm trying to display value from my database with special formation
I store a String in my database which Looks like this 40;99;1;0;0;12
These are six different numbers seperated with a ;and they have a range between 0-99.
I want to display this value in an InputMask to make sure that the user doesn't forget the ;.
Now I have a problem with the format.
I'm using this
<p:inputMask id="myID" placeholder="Value" value="#{myClass.value}" mask="9?9;99;99;99;99;99"/>
I'm trying to say that the mask contains six "fields" for a number input and each field can contain a number between 1-99.
The problem is if the user writes the input as this 30;10;0_;0_;0_;4_Primefaces converts it to 30;10;00;04;__;_
Is there a good way to let the mask know that it can be a number with one or two digits?
Or is there a way to say, if input has just one digit put a 0 first
I dont know if this solution fits your needs, but you can define a custom mask
$.mask.definitions['h'] = "[0-9]{0,1}";
$("#form\\:your_input_mask_id").mask("hh;hh;hh;hh;hh;hh");
in your document.ready function. This will leave the _ character as is, but I guess you can handle it in your code when splitting the string and handling each part. I've put form\: because you generally put these inputs inside a form with id form. Change accordingly!
This has the downside though, that if you dont enter something, it will also validate, regardless of not being between 1 and 99.
I have a Xpage with three fields, all Number declared; Nominal, Price and PaymentAmount.
I want to calculate the PaymentAmount using Nominal * Price.
In SSJS onChange I use the following code:
var price = getComponent("Price").getValue();
to get the value from the field "Price".
In Sweden we enter our numeric values as this #.###,## 1.234,56
If I enter the values Nominal=10 and Price=2,5 in my Xpage and try to calculate using the above mentioned formula the value stored in var "price" is converted to 25 and of type long.
Please advice
/M
I'm an idiot, unfortunatly.
Did this:
<inputText value="#{document1.Price}" id="Price" required="true" size="10">
<this.validators>
<validateRequired message="Price is required">
</validateRequired>
</this.validators>
<this.converter>
<convertNumber type="number" locale="sv">
</convertNumber>**
</this.converter>
</inputText>
and it works!
Thanks you ALL for input
I take it "Price" is an edit box? If so you can set it to Number field, then Display format to currency. The currency code will define how that number is displayed.
When you get the components value it should come back as a normal number you can work with.
getComponent gets the UI component value and that's why it does not necessarily reflect the data type that will be saved (in UI everything is string). It's also a slow way to get the value.
Try datasourcename.getItemValueDouble("itemname") instead. Note that you need to use the field name on Form, not the component name.
Regarding number format make sure your djConfig locale is Sweden, probably se-se. For me in Finland it looks like this:
<script type="text/javascript" src="/xsp/.ibmxspres/dojoroot-1.6.1/dojo/dojo.js" djConfig="locale: 'fi-fi', parseOnLoad: true"></script>
It should use the browser locale. To force this in SSJS you can do:
context.setLocaleString("se-SE");
in beforePageLoad event.
Im using glassfish 3.0.1 and was experimenting with columnClasses in dataTable for the first time.
It's something like this :
<h:dataTable value="#{coreGridBean.heroBeanList}" var="hero"
captionStyle="font-size: 0.95em; font-style:italic"
styleClass="orders"
headerClass="ordersHeader"
footerClass="ordersHeader"
columnClasses="oddColumn,evenColumn">
From the core jsf book im reading, it says that by specifying only 2 classes in the columnClasses attribute, those 2 will be repeated when the column amount is more than 2.
Let's say that i have five columns, the columnClasses would become something like oddColumn,evenColumn,oddColumn,evenColumn,oddColumn, and we just need to define it like this : columnClasses="oddColumn,evenColumn"
But in my experience with 3 columns, it's not like this. From the third column they got no classes. I had to specify columnClasses="oddColumn,evenColumn,oddColumn" to make it work
Is this a bug or i just have a bad error ?
The repetition only applies on rowClasses.
From the JSF 2.0 h:dataTable tag documentation:
columnClasses
Comma-delimited list of CSS style classes that will be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of actual column children of the UIData, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of actual column children of the UIData, the elements at the posisiton in the list after the last column are ignored.
rowClasses
Comma-delimited list of CSS style classes that will be applied to the rows of this table. A space separated list of classes may also be specified for any individual row. Thes styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again.
Maybe the book was wrong, or you misread the book.
Since the column number is usually always fixed in the view definition anyway, it's little effort to just repeat them yourself.
<h:dataTable columnClasses="oddColumn,evenColumn,oddColumn,evenColumn">
<h:column></h:column>
<h:column></h:column>
<h:column></h:column>
<h:column></h:column>
</h:dataTable>