How to load values from database into the f:selectItems value attribute
Hi,
I am trying to load the drop down menu value i.e f:selectItems from the database with a list of values from a column in the databse table. how can i do this? Should i use binding? or is there any other way.
Note:i am able to load values into f:selectItems from the faces-config.xml file but they are static values. i want the values from the database
Please reply with sample codes of faces jsp, bean file and config.xml file
But this is working for me,
JSF
<h:selectOneMenu value="#{loadbean.grade}" >
<f:selectItems value="#{loadbean.gradelist}" />
</h:selectOneMenu>
bean
private String grade;
private List<SelectItem> gradelist;
public String getGrade() {
return grade;
public void setGrade(String grade) {
this.grade = grade;
public List<SelectItem> getGradelist() {
return gradelist;
public void setGradelist(List<String> items) {
gradelist=new ArrayList<SelectItem>();
gradelist.add(new SelectItem("daniel"));//this value can be from data base
gradelist.add(new SelectItem("pspindia"));
gradelist.add(new SelectItem("prelude sys"));
faces-config.xml
<managed-property>
<property-name>gradelist</property-name>
<null-value/>
</managed-property>
this working fine for me. So setter method also works to load value for the h:selectItems
Thanks a lot.
Similar Messages
-
Fetching values from database into a drop down box
in my JSP page there are 3 drop down boxes for date of birth......
what i need is i want to get the values from database into that drop down box when i access the JSP page.......
session is there....'m getting all other values.......
I will attach the JSP page.....
Please help me...........
Thanks in Advance......
<%@ taglib uri='/WEB-INF/taglib/struts-bean.tld' prefix='bean'%>
<%@ taglib uri='/WEB-INF/taglib/struts-logic.tld' prefix='logic'%>
<%@ taglib uri='/WEB-INF/taglib/dyna.tld' prefix='dyna'%>
<%@ taglib uri='/WEB-INF/taglib/struts-html.tld' prefix='html'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><bean:message key="page_title"/></title>
<link href="<bean:message key="context"/>/CSS/default.css" rel="stylesheet" type="text/css" />
<script src="<bean:message key="context"/>/js/AC_RunActiveContent.js" type="text/javascript"></script>
<link href="<bean:message key="context"/>/CSS/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%!
Membership mShip = null;
%>
<script language="javascript" >
function checkDate(Form){
var d;
d = Form.year.value+"-"+Form.month.value+"-"+Form.day.value;
alert("Date is:"+d);
Form.dob.value = d;
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<jsp:include flush="true" page="../templates/header.jsp"/> </td>
</tr>
<tr>
<td class="menuTD">
<jsp:include flush="true" page="../templates/menu.jsp"/> </td>
</tr>
<tr>
<td class="sub_menuTR"> </td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="column" valign="top" width="170"><jsp:include flush="true" page="../templates/left_panel.jsp"/></td>
<td valign="top" align="left">
<dyna:message error="error" warning="warning" message="message"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80%" valign="top" align="left">
<%
if(session != null){
mShip = (Membership)session.getAttribute("member");
%>
<form action="updateContactDetails.dy" method="post" name="form1">
<input type="hidden" name="m" value="<%=request.getParameter("m")%>" />
<table width="100%" border="0">
<tr>
<td>First Name</td>
<td><input name="first_name" type="text" id= "first_name" value = "<bean:write name = "member" property = "first_name" />" /></td>
</tr>
<tr>
<td>Last Name </td>
<td><input name="last_name" type="text" id="last_name" value = "<bean:write name = "member" property = "last_name" />" > </td>
</tr>
<tr>
<td>Address</td>
<td><input name="address1" type="text" id="address1" value = "<bean:write name = "member" property = "address1" />" ></td>
</tr>
<tr>
<td> </td>
<td><input name="address2" type="text" id="address2" value = "<bean:write name = "member" property = "address2" />" ></td>
</tr>
<tr>
<td>Suburb/City </td>
<td><input name="city" type="text" id="city" value= "<bean:write name = "member" property = "city" />" ></td>
</tr>
<tr>
<td>State/Territory</td>
<td><input type="text" name="state" value = "<bean:write name = "member" property = "state" />" ></td>
</tr>
<tr>
<td>Postcode</td>
<td><input type="text" name="postcode" value = "<bean:write name = "member" property = "postcode" />" ></td>
</tr>
<tr>
<td>Contact Phone</td>
<td><input type="text" name="home_phone" value = "<bean:write name = "member" property = "home_phone" />" ></td>
</tr>
<tr>
<td>Mobile</td>
<td><input type="text" name="mobile" value = "<bean:write name = "member" property = "mobile" />" ></td>
</tr>
<tr>
<td>Date of birth</td>
<td nowrap="nowrap"><select name="day">
<option>Day</option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="month">
<option>Month</option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">Decembber</option>
</select>
<select name="year" onChange = "checkDate(this.form);" >
<option>Year</option>
<option value="1957">1957</option>
<option value="1956">1956</option>
<option value="1955">1955</option>
<option value="1954">1954</option>
<option value="1955">1955</option>
<option value="1956">1956</option>
<option value="1957">1957</option>
<option value="1958">1958</option>
<option value="1959">1959</option>
<option value="1960">1960</option>
<option value="1961">1961</option>
<option value="1962">1962</option>
<option value="1963">1963</option>
<option value="1964">1964</option>
<option value="1965">1965</option>
<option value="1966">1966</option>
<option value="1967">1967</option>
<option value="1968">1968</option>
<option value="1969">1969</option>
<option value="1970">1970</option>
<option value="1971">1971</option>
<option value="1972">1972</option>
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>
<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
<option value="1991">1991</option>
<option value="1992">1992</option>
<option value="1993">1993</option>
<option value="1994">1994</option>
<option value="1995">1995</option>
<option value="1996">1996</option>
<option value="1997">1997</option>
<option value="1998">1998</option>
<option value="1999">1999</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
</select ></td></tr>
<tr>
<td><input type="hidden" name = "dob" /> </td>
<td nowrap="nowrap"><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</td>
<td width="40"></td>
<td width="200" valign="top">
<div id="headlines">
<jsp:include flush="true" page="../templates/profile.jsp"/>
</div>
</td>
</tr>
</table>
</td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td><jsp:include flush="true" page="../templates/footer.jsp"/></td>
</tr>
</table>
</body>
</html>i think normally u will get data from databsae as objects.they are like java beans having getter and setter methods.so you create a collection of those objects like collect all the objects coming from database into an arraylist or....
suppose you want to populate the dropdown box with say "username" from database object s, your code will look like that
<html:select property="name">
<html:options collection="databaseList" property="username" />
</html:select>
"databaseList" is collection(say.. ArrayList) of objects you are getting from database.this dropdown will contain all the "usernames" you are getting from database. -
How to load data from Quikbooks into PeopleSoft General Ledger module ?
Folks,
Hello.
My client's data is currently stored in Quikbooks.
After install PeopleSoft FSCM 9.0, I need to load the data from Quickbooks into PeopleSoft General Ledger module. But I don't know how to use PeopleSoft Integration Broker to integrate with Quikbooks.
Can any folks tell me how to load data from Quikbooks into PeopleSoft General Ledger module ?Hi,
If the data load is one time process, then you can use PL/SQL or datamover to load the data to PeopleSoft application.
If you want to load the data in real time, then you need to create In-bound and out-bound nodes to perform the transaction.
Thanks
Soundappan -
SAP Add On: How to load data from database to a matrix
I am making a payroll application add-on for SAP Business One. I have made a form using screen painter and wanted to know how one goes about loading data from a database into the matrix columns.
My matrix has 6 columns and have called the items;
public void DeclareColumsInMonthlyMatrix()
SAPbouiCOM.Item oItem = null;
// Adding the Monthlymatrix Elements
oItem = _form.Items.Item("matMonthly");
oMatrix = oItem.Specific;
oColumns = oMatrix.Columns;
oColumn = oColumns.Item("mPayYear");
oColumn = oColumns.Item("mMonth");
oColumn = oColumns.Item("mStartDate");
oColumn = oColumns.Item("mEndDate");
oColumn = oColumns.Item("mPayStatus");
oColumn = oColumns.Item("mTaxMethod");
I have retrieved the appropriate data from the database using LinQ to SQL and I have:
// Populate the Monthly Period Data Grid View
var monthlyPeriods = Program.Kernel.Get<IMonthlyPeriodService>().GetAllMonthlyPeriods();
monthlyPeriods = monthlyPeriods.OrderBy(x => Enum.Parse(typeof(MonthsOfAYear), x.Code, true));
The corresponding field names in the database for the 6 columns are:
U_Payroll_Year,
U_Month,
U_Starting_date,
U_Ending_date,
U_Pay_Process_Status,
U_Tax_Method
I was previously using C# .Net win forms and was using a datagrid and bindingsource which was easy by using the code
// Populate the Monthly Period Data Grid View
var monthlyPeriods = Program.Kernel.Get<IMonthlyPeriodService>().GetAllMonthlyPeriods();
monthlyPeriods = monthlyPeriods.OrderBy(x => Enum.Parse(typeof(MonthsOfAYear), x.Code, true));
monthlyPeriodBindingSource.DataSource = monthlyPeriods.ToList();
How do I achieve the same in SAP? How do I get the returned results from monthlyperiods to map over the appropriate columns in my matrix?Hi Nor,
you could build a function which is able to generate a list of koordinates from your geometry.
The file generated will be a character-separated list.
This list will be generated by using a simple select statement like this:
<font color="FFFF00">
select obj_id, mysdo_koo2list(geometry) from my_geotable where ... ;
</font>
the function mysdo_koo2list(..) have to be built by you first.
<em>create function mysdo_koo2list ( gc sdo_geometry) return varchar2 as
line varchar2(4000);
n number;
ordinate number;
begin
line:= ''; n := 0;
for ordinate in gc.sdo_ordinates.FIRST .. geom.sdo_ordinates.LAST
loop
line := line||to_char(geom.sdo_ordinates(ordinate), '9999999D999');
if ( mod(n,2) = 1 ) then
line := line||chr(10);
else
line := line||',';
end if;
n := n +1 ;
-- exit when n >330;
end loop;
return (line);
end;
</em> -
How to retrieve data from database to the structure(complicated)
Hello everyone:
I want to retrieve data from database to the structure. but the structure defined like this below:
TOLERANZOB LIKE QAMV-TOLERANZOB
TOLERANZOB1 LIKE QAMV-TOLERANZOB
so how can I retrieve the data from the database ? make sure that the two fields contain data both.
Thanks in advance .
Regards
NickHi Nick,
To retreive data for TOLERANZOB from QAMV,
If you know the key fields then use
SELECT SINGLE TOLERANZOB FROM QAMV INTO TOLERANZOB WHERE keyfields.
else, you can use
SELECT TOLERANZOB FROM QAMV UPTO ONE ROWS INTO TOLERANZOB WHERE....
Once you retreive the data using the select query, you can check if it is initial and if not move the data from TOLERANZOB to TOLERANZOB1.
<b>Reward points for helpful answers.</b>
Best Regards,
Ram. -
How to populate values from database into a Combo Box?
Hi,
How to display all the values of a field of a database table in a combo box inside a grid in B1 user defined form?
Regards,
Sudeshna.Hi,
If you are trying to do this on a system form (I gues this is your case, reading the other question), for example Sales Orders, and you want to show the values from a User Defined Table (UDT), you just need to add a User Defined Field on Marketing Documents Line level, and say it is linked to the UDT.
SBO will automatically show the combo with the values on the Code field of the UDT.
Regards,
Ibai Peña
Sorry, I didn´t read the post well.
What you could do is each time the form is loaded, read the values from the table, and asign them as Valid Values for the combobox column. You can do this programatically, or using XML (which is recommended becouse of better performance).
Message was edited by: Ibai Peña -
How to load a XML file into the database
Hi,
I've always only loaded data into the database by using SQL-Loader and the data format was Excel or ASCII
Now I have to load a XML.
How can I do?
The company where I work has Oracle vers. 8i (don't laugh, please)
Thanks in advance!Hi,
Tough job especially if the XML data is complex. The have been some similar question in the forum:
Using SQL Loader to load an XML File -- use 1 field's data for many records
SQL Loader to upload XML file
Hope they help.
Regards,
Sujoy -
How to load hierarchy from file into InfoObject with compounding Attr & LN
Hi,
I have created an InfoObject called YCOSTC0 which has a compounding attribute 0CO_AREA. and Text is Lanugage dependent, hence the key is YCOSTC0, 0CO_AREA and LANGUAGE, now when i load hierarchy from flat file as mentioned below, it creates duplicate blank rows in master data table, becuase the flat file contains only the YCOSTC0 Info Object and this data gets loaded into 0CO_AREA column in master data table which is the first column. how can i load hierarchies from flat file into an InfoObject that has a compounding attribute and Language dependent. please provide me a sample file structure with data.
NodeID InfoObject Node Name Link Name Parent ID Language Short Text Medium Text Long Text
1 0HIER_NODE CC_HIER EN Cost Center Heirarchy Cost Center Heirarchy Cost Center Heirarchy
2 YCOSTC0 C001 1 EN CC 1 Cost Center 1 Cost Center 1
3 YCOSTC0 C002 2 EN CC 2 Cost Center 2 Cost Center 2
4 YCOSTC0 C003 2 EN CC 3 Cost Center 3 Cost Center 3
5 YCOSTC0 C004 3 EN CC 4 Cost Center 4 Cost Center 4
6 YCOSTC0 C005 3 EN CC 7 Cost Center 7 Cost Center 7
7 YCOSTC0 C006 4 EN CC 5 Cost Center 5 Cost Center 5
8 YCOSTC0 C007 4 EN CC 8 Cost Center 8 Cost Center 8
9 YCOSTC0 C008 4 EN CC 10 Cost Center 10 Cost Center 10
10 YCOSTC0 C009 7 EN CC 6 Cost Center 6 Cost Center 6
11 YCOSTC0 C010 6 EN CC 9 Cost Center 9 Cost Center 9
Thanks
Akila RHi -
Check the following link.
Hierarchy Upload from Flat files
Anesh B -
How to put data from database into array
I need to answer hot to put data from database directly into array.
I tried like the code below but the error message said: java.lang.ArrayIndexOutOfBoundsException: 0, and it points to this line: numbers [row][0]= rs.getString("ID");
Hope you can help.
ResultSet rs = stmt.executeQuery(query);
int row=0;
String [] [] numbers=new String [row][10];
// output resultset
while ( rs.next() )
numbers [row][0]= rs.getString("ID");
numbers [row][1]= rs.getString("name");
row++;
// close resultset
rs.close();
thanks,DeviThe exception is been thrown simply because you assigned '0' to the 'row' variable, indicating a zero length of the array. In fact you should assign the row count to it.
After all, don't do that. Make use of the Collection framework and map the ResultSet to a Collection of DTO's.
List<User> users = new ArrayList<User>();
while (resultSet.next()) {
User user = new User();
user.setID(resultSet.getString("ID"));
user.setName(resultSet.getString("name"));
users.add(user);
} -
How to Retrieve data from database into another form ?
Good Day!
Am currently new at JSP. I've been studying it for awhile and still getting the hang of it. We are working on a project.
Editing a given data. We have to retrieve the given data and post it to another form "Editing form".
Since we can retrieve data using JSP but how are we going to post it to another form? I mean how are we going to transfer data from one form to another?
Can anyone help me with codes please..The client is a web browser.
The client submits a request (click a link, visit a form)
The server gets to respond to this
- look at request parameters from the client
- access database
- produce resulting html page
- send page back to client.
The standard pattern is to retrieve data from the database in java code, and then load that data into a bean.
You then make that bean available as an attribute
It is then available for use in your JSP - either <jsp:useBean> tag or using ${ELexpressions}
All you can pass from the client to the server is request parameters - which are always strings.
Draw a picture of where the information is, and the information flows. Very rarely does it go directly from one "form" to another.
Cheers,
evnafets -
How to bind data (from database) to the Dictionary structure in Web Dynpro
Hi,
I am getting Hashtable object from the database related classes and I want to bind this data to the Dictionary field in Web Dynpro. So, I can bind this Dictionary field type to the Context variable.
Please let me know the detailed procedure.
Thanks
Tatayya MTatayya,
Look at this sample tutorial , It will defintely help you with the Data Dictionary .
https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/bad3e990-0201-0010-3985-fa0936d901b4
https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/38650ecd-0401-0010-10a0-f9d8fd37edee -
How to load BeginningBalance and movements into HFM via FDM from ERPI
I have a file generated by ERPI with the columns of |AMOUNT|BEGIN_BALANCE_DR|BEGIN_BALANCE_CR|PERIOD_NET_DR|PERIOD_NET_CR|
among many other columns.
How can load them via FDM into the Custom1 dimension in HFM, which contains BeginningBalance, Additions, Disposals, etc.
So basically I will have a trial balance, which I can compare with GL and OBI.Hello
You can use the IDOC SOPGEN01 for that purpose.
Please check transaction WE60 for IDOC documentation and there are many old threads with information about this IDOC.
BR
Caetano -
Passing field value from appoinment into task
Hi,
I need to pass the field values from appointment into the task. I was able to pass values from one record type to another but in this case as both appointment and task belong to the same record type namely activity and they are having the same foreign key namely ActivityId.
So any one please tell me , is it possible to pass values from appointment in to the task or not ?
If so how?
Thanks,
Kirubahar.
Edited by: Kiruba on Mar 4, 2011 6:45 AMWrite a workflow and select the field you want to copy the value into in the Field Name and the value you want to copy in value field, you don't need to use joinfieldValue at all.
cheers
Alex -
How can i get the random values from database?
Hi,
i want to get random values from database.
I try my best find no solution
plz give solution in either sql query or java method.
thanks in advance.try this:
Give a numeric row-id to each row of database.
say (1-100) for 100 rows
In the program use random function to get random number between 0 and 1. this value u multiply with 100(or total number of rows) and take integer value of it . u then perform sql query to select the a row which matches randomly genarated value with row-id assigned to each row of database
madhu -
How to select value from database view with * in wher clause
Hi ,
I ahve a database view with some fields.
Now my requirement is to serach a single row on the basis of process type.
Process type can have values like ZBA,ZBC,ZBD,ZBE or similarly anything starting with ZB.
Now i know that starting two letters will be ZB , but dont knwo the last letter.
So how should i use select query for the same?
Should i use like operator for the same?
regards
PGhi,
u can use character '%'.sample code like this
SELECT reltype
instid_a
catid_a
instid_b
FROM /dbm/ord_docflow
INTO TABLE it_link
FOR ALL ENTRIES IN it_pnwtyh
WHERE instid_a = it_pnwtyh-instid_a AND
instid_b LIKE 'QMSM%' AND
typeid_a = 'BUS2400' AND
typeid_b = 'BUS2400' AND
catid_a = 'BO' AND
catid_b = 'BO' AND
reltype = 'VONA'.
this is similar to using* while we fetch values from table.in the above code only i no QMSM rest values not sure,so used QMSM%
Maybe you are looking for
-
Export project library to iPhoto
I have created a rough montage in iMovie using only still photos. I need to hand the files and the running order over to a third party to finish the job. He may or may not be using iMovie. Is there a way to print a list of the images in the order tha
-
Copying non-itunes files from iphone to itunes
how can i copy files not purchased from itunes that are on my iphone to a new itunes library floowing a computer crash
-
Upgrade mountain lion, cant restore back up n iLife apps missing
i had upgrade my macbook to mountain lion, now i cant restore my back up from my time machine and all my iLife apps and Microsoft 2008 missing. How can I get it back?
-
Install JavaDB with no root access?
I cannot access my Linux server as root. That means that I cannot execute files. Is it possible for me to simply upload the JavaDB files and make it work as a database? Install it without root access? How about MySQL? Can I also do the same (just upl
-
JBO-26031 Error encountered when attempting to create new row
Hi We are experiencing an intermittent error whereby sometimes the call to View1Impl.createRow() fails with the following error message: JBO-26031 Association end Entity1 of assoc Entity1Entity2FkAssoc invalid for entity based Entity1 in view object