What does h:dataTable bodyrows attribute mean - jsf

Does anybody know what h:dataTable bodyrows means? I tried a simple example, but I don't understand what it's supposed to do.
<h:dataTable bodyrows="d" value="#{index.publishDates}" var="d">
Is this some sort of shortcut for making a table? I don't see any rows because of the bodyrows annotation. If h:column does columns, what does bodyrows do?
I don't understand the documentation.
This must be a comma separated list of integers. Each entry in this list is the row index of the row before which a "tbody" element should be rendered.

In HTML, a <table> can have multiple bodies via <tbody>.
<table>
<tbody>...</tbody>
<tbody>...</tbody>
<tbody>...</tbody>
</table>
By default, a <h:datatable> generates only one body like below.
<h:dataTable value="#{[1,2,3,4,5]}" var="i">
<h:column>#{i}</h:column>
</h:dataTable>
<table>
<tbody>
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
<tr><td>5</td></tr>
</tbody>
</table>
The bodyrows attribute can be used to specify a commaseparated string of row indexes which should start as a new body.
<h:dataTable value="#{[1,2,3,4,5]}" var="i" bodyrows="0,2,4">
<h:column>#{i}</h:column>
</h:dataTable>
<table>
<tbody>
<tr><td>1</td></tr>
<tr><td>2</td></tr>
</tbody>
<tbody>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
</tbody>
<tbody>
<tr><td>5</td></tr>
</tbody>
</table>
See also:
Can we have multiple <tbody> in same <table>?
HTML Dog HTML beginner tutorial - tables
MDN HTML element reference - table

Related

How to iterate through a list of list in jsp

I have list of list in a java class. I want to display list of list in JSP.
Java code
ArrayList<ArrayList<String>> criteriaList;//have getter,setter
JSP Code
<s:iterator value="criteriaList" status="status">
<tr><td>
<s:property value="[#status.index]" />
</tr></td>
</s:iterator>
But can't working.
As copied out of the struts documentation.
Iterating over a list of lists
<table>
<s:iterator value="grid">
<tr>
<s:iterator value="top">
<td><s:property/></td>
</s:iterator>
</tr>
</s:iterator>
</table>
The trick here is to use 'top' as the value for the inner iterator. This example probably uses a two-dimensional array, but you can use the pattern for any list of lists.

xpages dijit.form.checkbox multiple values

Using xpages on domino 8.5.3 server.
Can a djcheckbox be use with muiltiple value field similar to a checkboxgroup ?
if so, would it be possible to supply a code snippet.
Thanks
dijit.form.CheckBox can deal with only one value and that's true for djCheckBox too as it's based on dijit.form.CheckBox.
You could combine several djCheckBox controls and let it look like a checkBoxGroup. Bind every djCheckBox to a viewScope variable initialized by a document item and write values back at document save.
Here is an example for UI similarity to checkBoxGroup:
<fieldset
class="xspCheckBox">
<table>
<tbody>
<tr>
<td>
<xe:djCheckBox
label="abcdefg"
id="djCheckBox4"
value="#{viewScope.abcdefg}">
</xe:djCheckBox>
</td>
<td>
<xe:djCheckBox
label="hijklmno"
id="djCheckBox5"
value="#{viewScope.hijklmno}">
</xe:djCheckBox>
</td>
<td>
<xe:djCheckBox
label="pqrstuvwxyz"
id="djCheckBox6"
value="#{viewScope.pqrstuvwxyz}">
</xe:djCheckBox>
</td>
</tr>
</tbody>
</table>
</fieldset>
I am not sure though what's the reason for your question and if it's worth the extra effort.

Extracting specific values with Postgresql

I have a table like this:
Table
<!DOCTYPE html>
<html>
<body>
<table border="1" style="width:100%">
<tr>
<td>email</td>
<td>data</td>
</tr>
<tr>
<td>creator_a#creator.com</td>
<td>"vimeo_profile"=>"", "twitter_profile"=>"", "youtube_profile"=>"", "creator_category"=>"production_company", "facebook_profile"=>"", "linkedin_profile"=>"", "personal_website"=>"", "instagram_profile"=>"", "content_expertise_categories"=>"4,5,8"</td>
</tr>
<tr>
<td>creator_b#creator.com</td>
<td>"twitter_profile"=>"", "creator_category"=>"association", "facebook_profile"=>"", "linkedin_profile"=>"", "personal_website"=>"", "content_expertise_type"=>"image", "content_expertise_categories"=>"4, 6"</td>
</tr>
</table>
</body>
</html>
And I want to query this using PostgreSQL, so I only get the values regarding content_expertise_categories:
*Important to mention that the number of values vary. The table has many more entries so I am looking for a solution that helps me extract the values regardless of whether there are 2 or 15 values to pull out.
Result
<!DOCTYPE html>
<html>
<body>
<table border="1" style="width:100%">
<tr>
<td>email</td>
<td>data</td>
</tr>
<tr>
<td>creator_a#creator.com</td>
<td>4,5,8</td>
</tr>
<tr>
<td>creator_b#creator.com</td>
<td>4,6</td>
</tr>
</table>
</body>
</html>
I have tried substring but can't make it to work.
Some help would be much appreciated, thanks!
SELECT
email,
(string_to_array(
data::text,'"content_expertise_categories"=>'::text
)
)[2] as data
FROM users
;
Update:
In your example all strings have "content_expertise_categories" listed last, which allows to think you can just split string to two pieces. If you happen to have more php array definition values after, you'll need an additional split on ',"' and taking [1] part this time...
Mind casting column "data" to ::text before using it in content_expertise_categories function, as it requires text type, and your column appeared to be not such.
I believe more elegant would be this query:
select
email,
data->'content_expertise_categories' as data
from h
;
But when I was posting first query I did not know that you use hstore

rich faces selectionChangeListener for two different column

I have a richtree like this :
<rich:tree id="positionTree"
value="#{positionAdminBean.positionTree}"
var="pos" switchType="ajax" binding="#positionAdminBean.htmlTree}"
nodeSelectListener="#{positionAdminBean.onCmdSelectPosition}"
ajaxSubmitSelection="true" reRender="positionPanel,mainTabbedPane,selectGroupPanel">
<rich:treeNode id="treeNodeId">
<table width="100%">
<tr>
<td width="50%">
<h:outputText value="#{pos.name}" id="treeposNameId"/>
</td>
<td width="40%">
<h:outputText value="#{pos.humanResourceName}" id="treeposHumanResName"/>
</td>
</tr>
</table>
</rich:treeNode>
</rich:tree>
these codes generate and show a tree of data correctly.
but my problem is that when you click on a row it fires nodeSelectListener="#{positionAdminBean.onCmdSelectPosition}".
as you see my tree has two columns , I need to do something with this code that every columns has its own select listener .
or do something that when user click on each columns it does different works
Well, a nodeSelectListener is fired when a node is selected. You can not assign it to something that is only a part of the node.
You can define an <a4j:jsFunction> and call it when the table cell is clicked.
<a4j:jsFunction name="firstColumnListener" actionListener="#{bean.doSomething}" … >
<a4j:param name="id" assignTo="#{bean.selectedId}" />
</a4j:jsFunction>
<td onclick="firstColumnListener(id)">
…
</td>

JavaFX hide text of column in tableview

I have a tableview and I want to show an image in the first column. My problem is I can't sort the column then. My idea is to set text in the column too and hide the text so it is only for the correct sorting set. Is there a way to do that? Or what other solutions are possible for my problem?
I think this is the perfect example what you wants to do.Still let me know if you have any issue.
Check here
I would have a look at TableColumn.setCellValueFactory() and TableColumn.setCellFactory(). The further is used to provide the actual cell value (used for sorting!), the latter is used to provide the rendering.
In other words: If you need the sort order, you must not change the content, but only the Cell rendering. The methods mentioned above let you do exactly this.
Hope that helps ...
You could do it with just CSS using text-indent. You would also need to set the image as a css background. You did not provide an code of your table, but below is some example:
HTML:
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td class="hidetext image">Text 1</td>
<td>Some text to show</td>
</tr>
<tr>
<td class="hidetext image">Text 2</td>
<td>Some text to show</td>
</tr>
<tr>
<td class="hidetext image">Text 3</td>
<td>Some text to show</td>
</tr>
<tr>
<td class="hidetext image">Text 4</td>
<td>Some text to show</td>
</tr>
</table>
CSS:
.hidetext {text-indent:-9000px}
.image {background:url(http://www.madisoncopy.com/images/jpeg.jpg) no-repeat;}
See how in the left column the text does not show (but it is actually there just indented off the screen).
See this fiddle: http://jsfiddle.net/D297P/

Resources