How to output a list of strings in JSF as comma-separated strings

--Environment - CentOS Linux release 7.8.2003 (Core) - openjdk version "11.0.7" 2020-04-14 LTS - JSF 2.3.9

スクリーンショット 2020-09-24 22.48.35.png

Method 1: Make Gettr for comma separated strings with Beab

Reference: Several ways to concatenate strings separated by commas in Java --Qiita

xhtml


<!--abridgement-->
<h5>Output a list of strings as comma-separated strings</h5>
<h:outputText value="#{sampleBean.commaDelimitedString}" />
<!--abridgement-->

SampleBean.java


//abridgement
/**List of strings. */
@Getter
private List<String> strings = Arrays.asList("Of the string", "List", "Separated by commas", "I want to display it.");

/**
 *Get a list of strings as comma separated strings.
 * @return Comma-separated string
 */
public String getCommaDelimitedString() {
    return this.strings.stream().collect(Collectors.joining(","));
}
//abridgement

Method 2: ʻui: repeat` in xhtml

xhtml


<!--abridgement-->
<ui:repeat var="string" value="#{sampleBean.strings}" varStatus="index">
  <h:outputText value="#{string}" />
  <ui:fragment rendered="#{!index.last}">,</ui:fragment>
</ui:repeat>
<!--abridgement-->

SampleBean.java


//abridgement
/**List of strings. */
@Getter
private List<String> strings = Arrays.asList("Of the string", "List", "Separated by commas", "I want to display it.");
//abridgement

Recommended Posts

How to output a list of strings in JSF as comma-separated strings
Cast an array of Strings to a List of Integers in Java
How to connect the strings in the List separated by commas
How to concatenate strings in java
How to sort a List using Comparator
How to sort the List of SelectItem
Ability to display a list of products
How to publish a library in jCenter
How to specify id attribute in JSF
How to get the current date as a string in yyyyMMdd format
How to change the value of a variable at a breakpoint in intelliJ
How to get the absolute path of a directory running in Java
Summary of how to select elements in Selenium
[java] Summary of how to handle character strings
(Memo) How to solve dummy output in Ubuntu 20.04
How to color code console output in Eclipse
How to display a web page in Java
How to run a djUnit task in Ant
How to create a theme in Liferay 7 / DXP
How to implement a like feature in Rails
How to easily create a pull-down in Rails
How to use JQuery in js.erb of Rails6
How to make a follow function in Rails
How to automatically generate a constructor in Eclipse
How to get the ID of a user authenticated with Firebase in Swift
[Rails] How to get rid of flash messages in a certain amount of time
Get the path defined in Controller class of Spring boot as a list
How to make a unique combination of data in the rails intermediate table
I made a sample of how to write delegate in SwiftUI 2.0 using MapKit
How to clear all data in a particular table
How to create a Java environment in just 3 seconds
[Ruby] How to use standard output in conditional branching
How to delete / update the list field of OneToMany
How to run the SpringBoot app as a service
How to implement a like feature in Ajax in Rails
How to input / output IBM mainframe files in Java?
How to create a Spring Boot project in IntelliJ
How to create a data URI (base64) in Java
How to save a file with the specified extension under the directory specified in Java to the list
How to launch another command in a Ruby program
Get a list of classes in a Guava specific package
[How to insert a video in haml with Rails]
Output a list of cron settings for all users.
How to store Rakuten API data in a table
How to mock a super method call in PowerMock
How to use CommandLineRunner in Spring Batch of Spring Boot
How to convert A to a and a to A using AND and OR in Java
How to convert a file to a byte array in Java
[Rails 6] How to set a background image in Rails [CSS]
Summary of how to implement default arguments in Java
[Rails] How to load JavaScript in a specific view
How to write a core mod in Minecraft Forge 1.15.2
Output in multiples of 3
[Ruby/Rails] How to generate a password in a regular expression
How to concatenate strings
How to request a CSV file as JSON with jMeter
How to change a string in an array to a number in Ruby
How to create a placeholder part to use in the IN clause
How to store a string from ArrayList to String in Java (Personal)
How to get the longest information from Twitter as of 12/12/2016
How to Burning a Install Disk of Windows from Ubuntu