How to use HtmlDataTable in JSF

Hi,
I am going to use HtmlDataTable in a bean. The scenario like this: User submit a symbol (a String) then get stock history information corresponding to this symbol. I put the stock history information in an Arraylist, every element of this Arraylist is a java bean, which contains historical information for this stock according to the time.
The java bean:
public class StockHistory {
     private String symbol;
     private String date;
     private long dayVolume;
     private double openPrice;
     private double closePrice;
     private double dayHighPrice;
     private double dayLowPrice;
     public String getSymbol()
          return symbol;
     public void setSymbol(String Symbol)
          this.symbol = Symbol;
     public String getDate()
          return date;
     public void setDate(String date)
          this.date = date;
     public long getDayVolume()
          return dayVolume;
     public void setDayVolume(long dayVolume)
          this.dayVolume = dayVolume;
     public double getOpenPrice()
          return openPrice;
     public void setOpenPrice(double openPrice)
          this.openPrice = openPrice;
     public double getClosePrice()
          return closePrice;
     public void setClosePrice(double closePrice)
          this.closePrice = closePrice;
     public double getDayHighPrice()
          return dayHighPrice;
     public void setDayHighPrice(double dayHighPrice)
          this.dayHighPrice = dayHighPrice;
     public double getDayLowPrice()
          return dayLowPrice;
     public void setDayLowPrice(double dayLowPrice)
          this.dayLowPrice = dayLowPrice;
}The Arraylist:
ArrayList data = new ArrayList( 100 );
Collection threadSafeList = Collections.synchronizedCollection( data );
StockHistory stock = new StockHistory();
stock.setSymbol("IBM");
stock.setDate("01/01/2000");
stock.setDayVolume(100000);
stock.setOpenPrice(76.08);
stock.setClosePrice(78.08);
stock.setDayLowPrice(75.05);
stock.setDayHighPrice(79.93);
data.add(stock);
stock.setSymbol("IBM");
stock.setDate("01/01/2002");
stock.setDayVolume(100300);
stock.setOpenPrice(86.08);
stock.setClosePrice(88.08);
stock.setDayLowPrice(85.05);
stock.setDayHighPrice(89.93);
data.add(stock););
I set HTMLDataTable lke:
// DataTable
historyDataTable = new HtmlDataTable();
// Column1
UIColumn columnComponent  = new UIColumn();
List childrenList = historyDataTable.getChildren();
childrenList.add(columnComponent);
// Header information 1
HtmlOutputText headerComponent = new HtmlOutputText();
headerComponent.setValue("symbol");
columnComponent.setHeader(headerComponent);
// Column 2
columnComponent  = new UIColumn();
childrenList.add(columnComponent);
// Header information 2
headerComponent = new HtmlOutputText();
headerComponent.setValue("date");
columnComponent.setHeader(headerComponent);
// Column3
columnComponent  = new UIColumn();
childrenList.add(columnComponent);
// Header information 3
headerComponent = new HtmlOutputText();
headerComponent.setValue("dayVolume");
columnComponent.setHeader(headerComponent);
// Column 4
columnComponent  = new UIColumn();
childrenList.add(columnComponent);
// Header information 4
headerComponent = new HtmlOutputText();
headerComponent.setValue("openPrice");
columnComponent.setHeader(headerComponent);        
// Column5
columnComponent  = new UIColumn();
childrenList.add(columnComponent);
// Header information 5
headerComponent = new HtmlOutputText();
headerComponent.setValue("closePrice");
columnComponent.setHeader(headerComponent);
// Column 6
columnComponent  = new UIColumn();
childrenList.add(columnComponent);
// Header information 6
headerComponent = new HtmlOutputText();
headerComponent.setValue("dayHighPrice");
columnComponent.setHeader(headerComponent);
// Column 7
columnComponent  = new UIColumn();
childrenList.add(columnComponent);
// Header information 7
headerComponent = new HtmlOutputText();
headerComponent.setValue("dayLowPrice");
columnComponent.setHeader(headerComponent);
//get data
ArrayList list=history(symbol);
list=(ArrayList) columnComponent.getChildren();
for(int i=1; i<=list.size(); i++)
     HtmlOutputText rowComponent = new HtmlOutputText();
     rowComponent.setValue("Row"+i);
     rowComponent.setId("Row"+i);
     list.add(rowComponent);
// DataModel
ListDataModel listDataModel = new ListDataModel();
listDataModel.setWrappedData(list);The JSP code to display this table
<h:dataTable id="Historytable" value="#{stockHistoryBean.historyDataTable}" var="varstockHistory" styleClass="dataTable" headerClass="headerClass" footerClass="footerClass" rowClasses="rowClass1" columnClasses="columnClass1" border="0" cellpadding="2" cellspacing="0" binding="#{stockHistoryBean.historyDataTable}">
<h:column id="column1" >
<f:facet name="header">
<h:outputText styleClass="outputText" value="DATE" id="col1text1"></h:outputText>
</f:facet>
<h:outputText id="col1text2" value="#{varstockHistory.symbol}" styleClass="outputText" >
<f:convertDateTime/>
</h:outputText>
</h:column>
               <h:column id="column2" >
                    <f:facet name="header">
                    <h:outputText styleClass="outputText" value="DATE" id="col2text1"></h:outputText>
                    </f:facet>
                    <h:outputText id="col2text2" value="#{varstockHistory.date}" styleClass="outputText" >
                    <f:convertDateTime/>
                    </h:outputText>
               </h:column>
               <h:column id="column3" >
                    <f:facet name="header">
                    <h:outputText styleClass="outputText" value="Dayvolume" id="col3text1"></h:outputText>
                    </f:facet>
                    <h:outputText id="col3text2" value="#{varstockHistory.dayVolume}" styleClass="outputText" >
                    <f:convertNumber/>
                    </h:outputText></h:column>
                    <h:column id="column4" >
                    <f:facet name="header">
                    <h:outputText styleClass="outputText" value="Openprice" id="col4text1"></h:outputText>
                    </f:facet>
                    <h:outputText id="col4text2" value="#{varstockHistory.openPrice}" styleClass="outputText" >
                    <f:convertNumber/>
                    </h:outputText>
               </h:column>
               <h:column id="column5" >
                    <f:facet name="header">
                    <h:outputText styleClass="outputText" value="Closeprice" id="col5text1"></h:outputText>
                    </f:facet>
                    <h:outputText id="col5text2" value="#{varstockHistory.closePrice}" styleClass="outputText" >
                    <f:convertNumber/>
                    </h:outputText>
               </h:column>
               <h:column id="column6" >
                    <f:facet name="header">
                    <h:outputText styleClass="outputText" value="Dayhighprice" id="col6text1"></h:outputText>
                    </f:facet>
                    <h:outputText id="col6text2" value="#{varstockHistory.dayHighPrice}" styleClass="outputText" >
                    <f:convertNumber/>
                    </h:outputText>
               </h:column>
               <h:column id="column7" >
                    <f:facet name="header">
                    <h:outputText styleClass="outputText" value="Daylowprice" id="col7text1"></h:outputText>
                    </f:facet>
                    <h:outputText id="col7text2" value="#{varstockHistory.dayLowPrice}" styleClass="outputText" >
                    <f:convertNumber/>
                    </h:outputText>
               </h:column>
     </h:dataTable>The problem is when I tried to run, there is this page is not display. But if I remove the HTMLDataTable part from both bean class and JSP, then it works correctly. So much be something wrong with using HTMLDataTable.
Really appreciate your help

You should write your own JSF component that generates html frame as you need or
download already written custom component that generates html frame.

Similar Messages

  • How to use javascript for jsf containg t:htmlTags instead of panel grids

    Hi,
    i tried out validation in the following manner:
    function valid(form){
    alert(" 1:Entered valid function ");
    var varCritical1=document.form["form:critical1"].checked;
    var varHigh1=document.form["form:high1"].checked;
    if (varHigh1&&varCritical1){
    alert("Select only one option");
    document.form["form:critical1"].focus();
    document.form["form:high1"].focus();
    return false;
    return true;
    ====== the jsf code for the above is:
    <t:htmlTag value="td" style="border: 1px solid;">
    <h:commandButton id="commit" value="Commit all Changes" action="commit" styleClass="submit-button"
                                  onClick="return valid(this.form)" />
    </t:htmlTag>
    ======
    could anyone suggest me how to do this validation..
    faster reply is appreciated
    -Thanks,
    Soumya Desu

    When writing JS and you're new to JSF (so new that you don't know out of head which HTML a JSF component generate), you need to base the JS code on the generated HTML output, not on the JSF source code.
    For problems and/or support with writing JS code, please consult a JS forum. There are ones at webdeveloper.com and dynamicdrive.com. Please keep in mind that JSF source code is completely irrelevant for the JS forum users (and actually also for you), concentrate on and share the generated HTML output.

  • How to use Java Script in jspx pages of ADF Faces?

    I wanna invoke an Applet in a jspx using Java Script...
    How can I do this? :)

    check my other post..that's to know how to use js in jsf pages...not to invoke applet..
    Re: how to Add inline JavaScript to a Page 11G

  • Using Frames in JSF

    Can anyone provide an example on how to use frames inside JSF? I don't know how to define the framesets inside the jsf file. A simple example will go a long way. Thanks.

    Nope, I'm not big on samples, especially of code I've never tried to write. Give it a try, if you have a problem post your code and we'll take a look.

  • How to use one commandButton to execute two tasks in JSF

    I have a form in JSF page which contains different faces components. These faces bind to ADF BC to insert one row in the database when the user press commandButton. Also I need to bind the value of one inputText in that form to managed bean to execute another task in the application when the user press the same commandButton.
    The code of the inputText:
    <h:inputText value="#{bindings.ProjectNumber.inputValue}"
    id="pn"
    size="10"
    required="#{bindings.ProjectNumber.mandatory}">
    The code of commandButton:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}"/>
    The managed bean is �findInspector�. I tried to insert inputHidden inside commandButton tag and assign the value of the inputText to the inputHidden as follows:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}">
    <h:inputHidden value="#{bindings.ProjectNumber.inputValue}" binding="#{findInspector.project}"/>
    </h:commandButton>
    But it was not work
    Please how can I write the code to use the value of the inputText more than one time in the JSF(one to insert one row by using ADF BC and another to use the same value to bind to a managed bean) and how to use one commandButton to execute two tasks in JSF.
    Thank you
    Waheed

    Just dopublic void execute() {
        anotherAction(inputValue);
    I guess those articles might be interesting about passing params and the usage of inputHidden and also about using datatables:
    http://balusc.xs4all.nl/srv/dev-jep-com.html
    http://balusc.xs4all.nl/srv/dev-jep-dat.html

  • How to use one commandButton  to execute two task in JSF

    I have a form in JSF page which contains different faces components. These faces bind to ADF BC to insert one row in the database when the user press commandButton. Also I need to bind the value of one inputText in that form to managed bean to execute another task in the application when the user press the same commandButton.
    The code of the inputText:
    <h:inputText value="#{bindings.ProjectNumber.inputValue}"
    id="pn"
    size="10"
    required="#{bindings.ProjectNumber.mandatory}">
    The code of commandButton:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}"/>
    The managed bean is “findInspector”. I tried to insert inputHidden inside commandButton tag and assign the value of the inputText to the inputHidden as follows:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}">
    <h:inputHidden value="#{bindings.ProjectNumber.inputValue}" binding="#{findInspector.project}"/>
    </h:commandButton>
    But it was not work
    Please how can I write the code to use the value of the inputText more than one time in the JSF(one to insert one row by using ADF BC and another to use the same value to bind to a managed bean) and how to use one commandButton to execute two task in JSF.
    Thank you
    Waheed

    Yes I did
    <managed-bean>
    <description>The bean for get project No</description>
    <managed-bean-name>projectBean</managed-bean-name>
    <managed-bean-class>
    mcscm.model.ProjectBean
    </managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>bindings</property-name>
    <value>#{bindings}</value>
    </managed-property>
    </managed-bean>
    Also I changed the method in the managed bean as follows:
    public String commandButton_action() {
    FacesContext fctx = FacesContext.getCurrentInstance();
    ValueBinding vb = fctx.getApplication().createValueBinding("#{bindings}");
    DCBindingContainer dcb = (DCBindingContainer) vb.getValue(fctx);
    OperationBinding operation = (OperationBinding) dcb.get("projectNumber");
    operation.execute();
    return null;
    where projectNumber is my method in the java class of the application module "TaskInformationImpl". I made this method to be accessed from outside of ADF BC.
    I just create a sample code for projectNumber method for testing only as:
    public void projectNumber (String data){
    System.out.print(data);
    In the page Pagedef file I added this :
    <methodAction id="projectNumber"
    InstanceName="TaskInformationDataControl.dataProvider"
    DataControl="TaskInformationDataControl"
    MethodName="projectNumber" RequiresUpdateModel="true"
    Action="999" IsViewObjectMethod="false">
    <NamedData NDName="data" NDValue = "#{bindings.ProjectNumber.inputValue}" NDType="java.lang.String"/>
    After I did all of this I get a new error like:
    javax.faces.FacesException: #{projectBean.commandButton_action}: javax.faces.el.EvaluationException: java.lang.ClassCastException: oracle.adfinternal.view.faces.model.binding.FacesCtrlAttrsBinding cannot be cast to oracle.adf.model.OperationBinding
    Is it very difficult to do this in JDeveloper?. yes ADF BC provide me a lot of facilities, but when I want to do a specific task I face a lot of troubles

  • How to create a dynamic mapping of columnar at the Runtime using ADF or JSF

    How to create a dynamic GUI at the Runtime using ADF or JSF in JDeveloper 11g.
    What I am trying to build is to allow the user to map one column to another at the run time.
    Say the column A has rows 1 to 10, and column B has rows 1 to 15.
    1. Allow the user to map rows of the two tables
    2. An dhte rows of the two columns are dynamically generated at the run time.
    Any help wil be appreciated.....
    Thnaks

    Oracle supports feedback form metalink was; "What you exactly want to approach is not possible in Htmldb"
    I can guess that it is not
    exactly possible since I looked at the forums and documantation etc. but
    couldnt find anything similar than this link; "http://www.oracle.com/technology/products/database/htmldb/howtos/tabular_form.h
    t". But this is a very common need and I thought that there must be at least a workaround?
    How can I talk or write to Html Db development team about this since any ideas, this is very important item in a critial project?
    I will be able to satisfy the need in a functional way if I could make the
    select lists in the tabular form dynamic with the noz_id;
    SELECT vozellik "Özellik",
    htmldb_item.select_list_from_query(2, t2.nozellik_deger, 'select vdeger
    a,vdeger b from tozellik_deger where noz_id = 10') "Select List",
    htmldb_item.text(3, NULL, t2.vcihaz_oz_deger) "Free Text"
    FROM vcihaz_grup_ozellik t1, tcihaz_oz t2
    WHERE t1.noz_id = t2.noz_id
    AND t2.ncihaz_id = 191
    AND t1.ngrup_id = 5
    But what I exactly need i something like this dynamic query;
    SELECT
    vozellik "Özellik",
    CASE
    WHEN (t2.nozellik_deger IS NULL AND t2.vcihaz_oz_deger IS NOT NULL) THEN
    'HTMLDB_ITEM.freetext(' || rownum || ', NULL) ' || vozellik
    WHEN (t2.nozellik_deger IS NOT NULL AND t2.vcihaz_oz_deger IS NULL) THEN
    'HTMLDB_ITEM.select_list_from_query(' || rownum ||
    ', NULL, ''select vdeger a,vdeger b from tozellik_deger where noz_id = ' ||
    t1.noz_id || ''' ) ' || vozellik
    END AS "Değer"
    FROM vcihaz_grup_ozellik t1, tcihaz_oz t2
    WHERE t1.noz_id = t2.noz_id
    AND t2.ncihaz_id = 191
    AND t1.ngrup_id = 5
    Thank you very much,
    Best regards.
    H.Tonguc

  • How to use Apache MyFaces components in JSF pages + Eclipse?

    I've managed to write my JSF web app. in Eclipse jee, and test it on JBoss 4.2 GA, within Eclipse, but how to import Apache MyFaces components into Eclipse JSF plug-in?
    If I can't import it nicely, how to use those components directly in JSF pages?

    The Tomahawk component library provides MyFaces components. Install it as you would any other component library.
    http://myfaces.apache.org/tomahawk/

  • How to use web services in JSF app

    I am unsure if this is the right forum for this question. Let me know if it is not - and where I should go.
    Anyways, I'm building a JSF web app, in which there is a datatable page displaying some business data. The app is going to be deployed and run in the customer's web server, but the data to be displayed is from the business solution provider's database. Currently the provider supplies web services to retrieve the data. So, my task is to call these web services from my JSF page, get and display the data.
    I've never used web services before. Can someone give me a quick start, as what I need to know to use these web services, and how to use them in coding terms. I googled the web quite a bit and finally decided to turn to SDN forum.
    Thanks!

    http://help.sap.com/saphelp_nw04/helpdata/en/9b/dad1ae3908ee44a5caf57e10918be9/content.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/2d/64d029e74911d6b2e400508b6b8a93/content.htm

  • How to use ternary operator in JSF using EL expression

    how to use ternary operator in JSF using EL expression

    I want to use ternary operator for h:datatable columnclasses attribute like as below
    <h:datatable
    columnClasses="#{booleanExpression ? style1,style2 : style3,style4}"
    />
    But it's not working.Is there any other alternative to do this?

  • How Can I use EL in JSF

    Dear All
    I want to add If condition in JSF page .
    How can I use EL at JSF page
    I want ot Add If condition .
    With Thanks and Regards
    Gunjan Bohra

    Actually By Problem Is Regarding DataTable Binding Method
    <f:subview id="vesselist" rendered="#{vesselBaseVO.dfsVO.dfsData.dfsResultBeanListSize>0}" >
          <t:dataTable value="#{vesselBaseVO.dfsVO.dfsData.dfsResultBeanList}"     
                              sortable="false"
                              var="result"
                              id="dfsTable"
                               forceId="true"     
                              rowClasses="AlternateRow1, AlternateRow2"
                              columnClasses="TableColumnText, TableColumnText, TableColumnText, TableColumnText, TableColumnText, TableColumnText, TableColumnText, TableColumnNumber, TableColumnNumber, TableColumnText"
                              headerClass="TableHeader"
                              frame="box"
                              width="100%" 
                              preserveDataModel="false" 
                              rows="10" binding="#{vesselBackingBean.searchResultDataTable}" rendered="true">
               </t:dataTable>
    </f:subview>Although I had block it with renderer attribute ,
    DataTable would not show if resultList size is 0 but
    DATA Table binding method is still called even dataTable is not rendered on page I want to block that binding method calling ...
    How can I do that !!!!

  • How it use Filter Id and FilterPanelFocusid in JSF Table component

    How it use FilterId and FilterPanelFocusid in JSF Table component

    How it use FilterId and FilterPanelFocusid in JSF Table component

  • How to add fragment in jsf page using include tag in jdeveloper

    Hi all
    Can you tell me wat is syntax of using include tag .or how to add fragment in jsf page ..
    Edited by: 947228 on Jul 18, 2012 5:01 AM

    Hi,
    Why do you want to do that?
    Check [url https://blogs.oracle.com/jheadstart/entry/avoid_use_of_jspinclude_where]this out before proceeding further.
    Btw, always mention your JDev version, clear usecase to get help.
    -Arun

  • How to use Calander Component in JSF JSCreater

    i am using the calander component in JSCreter .
    i have one jsp page with a button and a calander component . If i let the calander field blank then the action event of button is fired but if i select some value in calandar field then then click the button then on action is fired
    what can be the reasion .

    I saw the documentation. But it uses com component which has ClassID / GUID. but how to use .net component and I think .net component doesn't maintain any registry information like classid / guid.

  • How to use java script in  sun stdio crator  jsf

    in sun stdio creator
    Checkbox cb;
    cb=new checkbox();
    ch. markforDeletion.setOnChange("submit()");
    it is giving identifier excepted .
    how to use setOnChange and other functio
    with regards
    shannu sarma

    in sun stdio creator
    Checkbox cb;
    cb=new checkbox();
    ch. markforDeletion.setOnChange("submit()");
    it is giving identifier excepted .
    how to use setOnChange and other functio
    with regards
    shannu sarma

Maybe you are looking for