JSF: How to get 2 columns from collection?
Using datatable i couldn't display 2 colums from collection. In JSF sun implementation is there any way to get?
my requriement is i need to display collection in matrix format 2*x
you can use ArrayDataModel object returned to the JSF page inoder to display multiple columes....
Similar Messages
-
Hi,
I have table called Employe. And the Columns are Emp_ID,EMP_NAME,SRC_SYS_CD,DOB
I have Query like
Select
COALESCE(MAX(CASE WHEN src_sys_cd='1' THEN Emp_id END), MAX(CASE WHEN src_sys_cd='2' THEN Emp_Id END))Emp_Id,
COALESCE(MAX(CASE WHEN src_sys_cd='1' THEN Emp_name END), MAX(CASE WHEN src_sys_cd='2' THEN Emp_Name END))Emp_name,
COALESCE(MAX(CASE WHEN src_sys_cd='1' THEN dob END), MAX(CASE WHEN src_sys_cd='2' THEN dob END))dob ,
from Employe
group by dob.
I want to generalize the query like get the columns from SYS.ALL_COLUMNS table for that table name and want to pass it to COALEACE() function. I tried with Cursor. But i didnt get the appropriate results.
Is there any way to achieve this? Please help me out in this regard.
Thanks,Is this the kinda thing you're after?
Add a filter to the queries to get just a single table/
WITH allCols AS (
SELECT s.name as sName, o.name AS oName, c.name AS cName, column_id,
CASE WHEN st.name in ('float','bigint','tinyint','int','smallint','bit','datetime','money','date','datetime2','uniqueidentifier','sysname','geography','geometry') THEN st.name
WHEN st.name in ('numeric','real') THEN st.name + '('+CAST(c.scale AS VARCHAR)+','+CAST(c.precision AS VARCHAR)+')'
WHEN st.name in ('varbinary','varchar','binary','char','nchar','nvarchar') THEN st.name + '(' + CAST(ABS(c.max_length) AS VARCHAR) + ')'
ELSE st.name + ' unknown '
END + ' '+
CASE WHEN c.is_identity = 1 THEN 'IDENTITY ' ELSE '' END +
CASE WHEN c.is_nullable = 0 THEN 'NOT ' ELSE '' END + 'NULL' AS bText,
f.name AS fileGroupName
FROM sys.columns c
INNER JOIN sys.objects o
ON c.object_id = o.object_id
AND o.type = 'U'
INNER JOIN sys.systypes st
ON c.user_type_id = st.xusertype
INNER JOIN sys.schemas s
ON o.schema_id = s.schema_id
INNER JOIN sys.indexes i
ON o.object_id = i.object_id
AND i.index_id = (SELECT MIN(index_id) FROM sys.indexes WHERE object_ID = o.object_id)
INNER JOIN sys.filegroups f
ON i.data_space_id = f.data_space_id
), rCTE AS (
SELECT sName, oName, cName, column_id, CAST(cName + ' ' + bText AS VARCHAR(MAX)) as bText, CAST(cName AS VARCHAR(MAX)) AS colList, fileGroupName
FROM allCols
WHERE column_id = 1
UNION ALL
SELECT r.sName, r.oName, r.cName, c.column_id, CAST(r.bText +', ' + c.cName + ' ' +c.bText AS VARCHAR(MAX)), CAST(r.colList+ ', ' +c.cName AS VARCHAR(MAX)), c.fileGroupName
FROM allCols c
INNER JOIN rCTE r
ON c.oName = r.oName
AND c.column_id - 1 = r.column_id
), allIndx AS (
SELECT 'CREATE '+CASE WHEN is_unique = 1 THEN ' UNIQUE ' ELSE '' END+i.type_desc+' INDEX ['+i.name+'] ON ['+CAST(s.name COLLATE DATABASE_DEFAULT AS NVARCHAR )+'].['+o.name+'] (' as prefix,
CASE WHEN is_included_column = 0 THEN '['+c.name+'] '+CASE WHEN ic.is_descending_key = 1 THEN 'DESC' ELSE 'ASC' END END As cols,
CASE WHEN is_included_column = 1 THEN '['+c.name+']'END As incCols,
') WITH ('+
CASE WHEN is_padded = 0 THEN 'PAD_INDEX = OFF,' ELSE 'PAD_INDEX = ON,' END+
CASE WHEN ignore_dup_key = 0 THEN 'IGNORE_DUP_KEY = OFF,' ELSE 'IGNORE_DUP_KEY = ON,' END+
CASE WHEN allow_row_locks = 0 THEN 'ALLOW_ROW_LOCKS = OFF,' ELSE 'ALLOW_ROW_LOCKS = ON,' END+
CASE WHEN allow_page_locks = 0 THEN 'ALLOW_PAGE_LOCKS = OFF' ELSE 'ALLOW_PAGE_LOCKS = ON' END+
')' as suffix, index_column_id, key_ordinal, f.name as fileGroupName
FROM sys.indexes i
LEFT OUTER JOIN sys.index_columns ic
ON i.object_id = ic.object_id
AND i.index_id = ic.index_id
LEFT OUTER JOIN sys.columns c
ON ic.object_id = c.object_id
AND ic.column_id = c.column_id
INNER JOIN sys.objects o
ON i.object_id = o.object_id
AND o.type = 'U'
AND i.type <> 0
INNER JOIN sys.schemas s
ON o.schema_id = s.schema_id
INNER JOIN sys.filegroups f
ON i.data_space_id = f.data_space_id
), idxrCTE AS (
SELECT r.prefix, CAST(r.cols AS NVARCHAR(MAX)) AS cols, CAST(r.incCols AS NVARCHAR(MAX)) AS incCols, r.suffix, r.index_column_id, r.key_ordinal, fileGroupName
FROM allIndx r
WHERE index_column_id = 1
UNION ALL
SELECT o.prefix, COALESCE(r.cols,'') + COALESCE(', '+o.cols,''), COALESCE(r.incCols+', ','') + o.incCols, o.suffix, o.index_column_id, o.key_ordinal, o.fileGroupName
FROM allIndx o
INNER JOIN idxrCTE r
ON o.prefix = r.prefix
AND o.index_column_id - 1 = r.index_column_id
SELECT 'CREATE TABLE ['+sName+'].[' + oName + '] ('+bText+') ON [' + fileGroupName +']'
FROM rCTE r
WHERE column_id = (SELECT MAX(column_id) FROM rCTE WHERE r.oName = oName)
UNION ALL
SELECT prefix + cols + CASE WHEN incCols IS NOT NULL THEN ') INCLUDE ('+incCols ELSE '' END + suffix+' ON [' + fileGroupName +']'
FROM idxrCTE x
WHERE index_column_id = (SELECT MAX(index_column_id) FROM idxrCTE WHERE x.prefix = prefix) -
How to get a column from a JTable whose columns may have been reordered
Hi,
After I have collected the indicies of the selected rows into an array, I now want to get a specific column. I am trying to use getColumnIndex method of the tableColumnModel. I don't know what to use for a paramater because I originally created the JTable as a vector of vectors. Can someone give me a detailed description of what to do? I am very new to Java.
Thanks!You most likely want to look at the method JTable.convertColumnIndexToModel(int).
http://java.sun.com/j2se/1.3/docs/api/javax/swing/JTable.html#convertColumnIndexToModel(int)
This should allow you to convert a column number you are used to into the new column number. -
How to get custom columns from Database in BO Universe
Hi,
We have 'n' databases. All the databases have identical tables and views but some tables in few database have custom columns.
Ex. 'database1' has table 'sites' with the following columns
1. sitenumber
2. sitename
3. siteaddress
4. phone
5. email
'database2' has table 'sites' with the following columns
1. sitenumber
2. sitename
3. siteaddress
4. phone
5. email
6. IsDepot
The condition says that
"If IsDepot field is present in the site table then list sites where IsDepot equals 0 or null otherwise list all sites"
How do i create a condition at the universe level which checks whether the object 'IsDepot" is present in the database or not.
A single universe needs to be created for this purposeHi,
We have implemented a solution for the IsDepot problem as mentioned above.
It is not done at the BO Universe level but at the SQL Server database level.
Steps Followed:
1. Created a stored procedure which checks the 'syscolumns' table for available fields
2. The SP creates a temp table with a value list based on previously mentioned conditions
3. This temp table can be used in the universe or a condition can be used to filter data based on this temp table.
Thanks,
Arun -
How to get SQL statement from (Collection) query.execute();
We have a JDO Persistence class ClassName that execute query using following code. After this statement get executed, record does not get updated in the DB. Is there a way to check what SQL statement got submitted in the (Collection) query.execute(); ??? <br><br>
Extent extent = pm.getExtent(ClassName.class, false); <br>
Query query = null; <br>
try { <br>
query = pm.newQuery(extent, filter); <br>
Collection results = (Collection) query.execute();<br>
Iterator i = results.iterator();<br>
if (i.hasNext()) {<br>
...<br>
}<br>You can always find out the names of tables that are views, using java.sql.DatabaseMetaData and its getTables() method.
This tends to be a nice source of examples:
javaalmanac.com
However, if you're asking for the underlying SQL used to CREATE VIEW, I don't see anything in the API that will give you that. After all, JDBC shouldn't have to know if it's dealing with an ordinary table or a view. I think you'd have to ask your DBA for the underlying SQL.
Once you have it, what do you plan to do with it?
% -
How to get string value from xml in JSF??
In JSF How to get string value from xml, .ini and properties file. I want to get string value from xml or text to JSF
Just use the appropriate API's for that. There are enough API's out which can read/parse/write XML, ini and properties files. E.g. JAXP or DOM4J for xml files, INI4J for ini files and Sun's own java.util.Properties for propertiesfiles.
JSF supports properties files as message bundle and resource bundle so that you can use them for error messages and/or localization. -
How to get the column index inside a dataTable
Hello,
before I get staked, there are multiple threads handling familiar topics to the one I'm questioning about but none gives an anwer. If there is one, I'm propably to less skilled to see it.
So here is my Problem: I've build a web-interface to a time-recording system. The hours worked on a certain project are displayed in a dataTable component which is generated out of a mySQL Query. Each entry (column/row) contains a inputText component to display and edit the specific value.
Editing one of these inputText elements now fires a valueChangeEvent which reads the new value and stores it in the database. For that cause I need to know the row- and column-index of the inputText component that fired the event.
Using the getClientId method from the valueChangeEvent I get some Information which makes it possible to calculate the row/column index. A typical clientID looks like "form_table:mainTable:0:_id14". "form_table" is the ID of the form the dataTable is in. "mainTable" is the id of the dataTable component. "0" is the row the component is in. And finally "_id14" stands for the id randomly given to the inputText component by JSF.
My Problem is now, that though I can calculate the column out of the[i] "_id14", this calculation is hardcoded. So everytime I add a component in before the dataTable, the calculation needs to be adjusted in the code.
The Questions:
- How to force a sensefull id indicating a column-index for the inputText components inside the columns of a dataTable?
- Nicer since no workaround: How to get the column-index inside the dataTable on a natural way? (e.g. out of the valueChangeEvent the specific inputText component fires)
After some investigation here on the board and on the net I know multiple ways to get the row index, (Things like component-binding and so on) but I can't find a answer on how to get the column-index.
Thanks to all answers and/or links to things my eyes missed while searching for one....then index 0 becomes index 1 and my program doesn't work properlyThe program works properly, just not as you expect it to.
As you've noticed the table gives you the flexibility to move columns around. So if you move column 0 to column 1, why would you expect to still use 0 as the index? The table manages the reordering of columns for you to make sure the data being displayed in each table column comes from the correct column in the data model.
You can manage this yourself using one of the following methods (I forget which one):
table.convertColumnIndexToModel(int viewColumnIndex)
table.convertColumnIndexToView(int modelColumnIndex)
Or, you can get data from the data model directly:
table.getModel().getValueAt(row, 0); -
How to get actual value from LOV list
Like Subject says: How to get actual value from LOV list. Any help will be appreciated.
Thanks.Thanks Shay, I did it with bind variable because I'm not using JSF. Is there any chance to post solution using standard JSTL or HTML expression. I have something like this: LOV displays some Companies names:
<html:select property="UserJobCompanyId"
disabled="${!bindings[\'UserJobCompanyId\'].updateable}"
onchange="submitform();">
<html:optionsCollection label="prompt" value="index" property="UserJobCompanyId.displayData"/>
</html:select>and I want to get CompanyID of selected Company.
Thanks, again. -
How to get real value from selectOneChoice with javascript?
Hi,
How to get real value from selectOneChoice with javascript? The event.getNewValue() only gets me the index of the selected item, not the value/title.
JSF page:
<af:resource type="javascript">
function parseAddress(event)
alert("new value: " + event.getNewValue());
</af:resource>
<af:selectOneChoice label="Location:" value="" id="soc4">
<af:clientListener type="valueChange" method="parseAddress" />
<f:selectItems value="#{Person.locations}" id="si7"/>
</af:selectOneChoice>
HTML :
<option title="225 Broadway, New York, NY-10007" selected="" value="0">225 Broadway (Central Office)</option>
<option title="90 Mark St., New York, NY-10007" value="1">90 Mark St. (Central Office)</option>
Thanks a lot.Something I was missing ,
You need to add valuePassThru="true" in your <af:selectOneChoice component. I have personally tested it and got the actual value in alert box. I hope this time you got the real solution. You can also test the following code by your end.
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1">
<af:form id="f1">
<af:panelBox text="PanelBox1" id="pb1">
<af:selectOneChoice label="Set Log Level" id="soc1"
value="#{SelectManagedBean.loggerDefault}"
valuePassThru="true">
<af:selectItem label="select one" value="First" id="s6"/>
<af:selectItem label="select two" value="Second" id="s56"/>
<af:clientListener method="setLogLevel" type="valueChange"/>
</af:selectOneChoice>
<af:resource type="javascript">
function setLogLevel(evt) {
var selectOneChoice = evt.getSource();
var logLevel = selectOneChoice.getSubmittedValue();
// var logLevelObject = AdfLogger.NONE;
alert("new value is : " + logLevel);
//alert(evt.getSelection);
//alert(logLevelObject);
evt.cancel();
</af:resource>
</af:panelBox>
</af:form>
</af:document>
</f:view>
</jsp:root> -
How to get the values from html:select? tag..?
i tried with this, but its not working...
<html:select styleClass="text" name="querydefs" property="shortcut"
onchange="retrieveOptions()" styleId="firstBox" indexed="true">
<html:options collection="advanced.choices" property="shortcut" labelProperty="label" />
</html:select>
<td align="left" class="rowcolor1">
<script language="javascript" type="text/javascript">
function retrieveOptions(){
var sel = document.querydefs.options;
var selectedOption = sel[sel.selectedIndex].value;
document.write(selectedOption);
</script><td align="left" class="rowcolor1">
<script language="javascript" type="text/javascript">
function retrieveOptions(){
var sel = document.querydefs.options;
var selectedOption = sel[sel.selectedIndex].value;
document.write(selectedOption);
</script>This java script is not working at all..its not printing anything in document.write();
This is code..
<td class="rowcolor1" width="20%">
<html:select styleClass="text" name="querydefs" property="shortcut"
onchange="retrieveSecondOptions()" styleId="firstBox"
indexed="true">
<html:options collection="advanced.choices" property="shortcut"
labelProperty="label" />
</html:select>i tried with this also. but no use..i'm not the getting the seleced option...
function retrieveOptions(){
firstBox = document.getElementById('firstBox');
if(firstBox.selectedIndex==0){
return;
selectedOption = firstBox.options[firstBox.selectedIndex].value;
}actually , how to get the values from <html:select> ...?
my idea is to know which value is selected from the combo box(<html:select> ) if that value is equal some string i have enable a hyperlink to open a popup window -
How to get the column names of the table into the Dashboard prompt
how to get the column names of the table into the Dashboard prompt
Thanks & Regards
Kishore PHey john,
My requirement is as follows
I have created a Rank for Total sales by Region wise i.e RANK(SUM(Dollars By Region)) in a pivot table.
My pivot table looks like this
COLUMN SELECTOR: TOTAL US , REGION , DISTRICT , MARKET
---------------------------------------------------- JAN 2009 FEB 2009 MAR 2009
RANK REGION DOLLARS DOLLARS DOLLARS DOLLARS
1 CENTRAL 10 20 30 40
2 SOUTHERN 10 30 30 70
3 EASTERN 20 20 20 60
4 WESTERN 10 20 30 40
When i select the District in column selector
Report has to display rank based on Total Sales by District. i.e
------------------------------------------------- JAN 2009 FEB 2009 MAR 2009
RANK DISTRICT DOLLARS DOLLARS DOLLARS DOLLARS
for this i need to change the fx of rank i.e RANK(SUM(Dollars By Region)) to RANK(SUM(Dollars By District)) and fx of Region i.e Markets.Region to Markets.District dynamically.
so , i need to capture column name of the value selected from the column selector and dynamically i need to update the fx 0f RANK & fx of region.
do you have any solution for this?
http://rapidshare.com/files/402337112/Presentation1.jpg.html
Thanks & Regards
Edited by: Kishore P on Jun 24, 2010 7:24 PM
Edited by: Kishore P on Jun 24, 2010 7:28 PM -
How to get the column count at the bottom of the column
Hi Friends,
How to get the column count at the bottom of the column
Thanks
RajYou mean row count? Add another column, click on the fx button and type RCOUNT(1).
If you want just the total you can make it MAX(RCOUNT(1)), hide this column and then add a Narrative View after your report and enter "Total Number of Records: @n" where "n" represents what order your column is from the left side. -
How to get 2 columns data in One Column
Hi,
I have requirement like below
EName Sal
Smith 1000
Scott 2000
Miller 3000
I want to display this two column like as follows
Emp
Smith
1000
Scott
2000
Miller
3000
Thanks & Regards,
Hari BabuHi,
That's called Unpivoting.
In Oracle 11.1 (and higher) you can use the SELECT ... UNPIVOT feature. For details and examples, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#sthref6810
In any version of Oracle, you can cross-join your table to any table or result set that has at least 2 rows, and use CASE (or DECODE) to get the results you want.
Remember that a column can only have 1 datatype: it's impossible to have a column that's a VARCHAR2 on some rows, but a NUMBER on other rows. You'll have to convert some data so that everything in the 1 output column has the same datatype. There's no way to express 'Smith' as a NUMBER, but you can convert all the NUMBERs to strings.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements), and also post the results you want from that data (if not what you posted already).
Post your best attempt at a query. Point out where it is getting the wrong results, and explain, using specific examples, how you get those results from the given data in those places.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
hi
i am new to programming... i would like to know how to get the column values... i have a resultset object
i need code .... asap
thnx@OP: It is always good to type complete sentences and describe your problem at length. It helps in letting people know what you really need instead of making wild guesses or silly jokes. You post mentions that you get the ResultSet. Then you should look up the API docs for java.sql.ResultSet and take a look at the getxxx() method signatures. Use the ones which suit the specific case.
Besides, it is good to refrain from using asap and urgent. Even if something is urgent to you, it need not be urgent to others. Wording a question properly would attract better replies.
Finally, would you mind getting down to specifics of your problem? From what I perceived, the JDBC tutorial and the API docs should provide all the information you need. -
Sending column from collection on email
How can I send on email column from collection? For example I've got collection:
ID Text Email
1 Hallo
[email protected]
and by clicking on button I want to send Text column on email provided in Email column
ThanksYeah I know. I can't do it 100% secure. But I'm not making app for banking system so I don't really worry about that. I'm making app for a company what has few conditions.
First:
The data can't be access or modify outside the company so the best thing would be to store all app data on company server and use company network to access them. I'm thinking about wifi. So for example I would install my app on my tablet (or in future in
my phone). Connect to company network over the wifi and import the data from within the app from the network. When I would be outside the company then I would lost connection with the data.
Here is the thread for that
Second:
The exported data or backup is not readable. At least not easy to read. So if someone would steal that backup would not be able to access them. Therefor I asked for coded exported file in
this thread
I know that not all of this is possible to do it now in sienna but at least I'm trying to do the best from sienna and hopefully upgrade that app in future if some of this option will be available in next sienna releases.
If that forgotten password is not possible to send on specific email then I replace it with some kinda memorable word for now ;(
Maybe you are looking for
-
How can I call the Class and have a PDF appear in seperate window?.
I would like to call the class/interface ZCL_UIU_PRN_ACCOUNT2, method Collect_data and have a Smartform executed to produce a PDF document in a Seperate window. Where I have an issue is in opening another window to display the PDF. I know the Standar
-
I've tried Windows Media Player, and Windows Movie Maker on Windows. On Mac, I've tried a few different things including Burn. For some reason i dont have iDVD. In my "About this Mac" it says that my optical drive can burn DVDs. It always goes throug
-
I am using the latest software and updates on both my iPad 2 and windows 7 32 bit laptop. I have reinstalled the latest edition of iTunes, and yet I still cannot do a synch to my iPad 2 as the computer shutdown during photo optimisation. I have even
-
Stock Transfer using Two Step (QI & Block stock)
Hi All , Is it possible to receive material QI / Blocked stock of receiving plant ?? Another query is ... can I transfer QI / Block stock of supplying plant to another plant ?? I have a business case where I have to transfer QI stock from one plant t
-
Deleted Allocation Table in vendor PO items
Hi guys, I write because it is having the problem I describe below: It creates an allocation table referencing a vendor PO. STO´s are created for each store included in the allocation rule in the allocation table. It is noted that there was an error