[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

problem displaying a list on a jsf table

Posted on 2007-08-02
3
Medium Priority
?
345 Views
Last Modified: 2013-11-23
hi,

I am using JSF as a controller for this application and am trying to display the contents of a list contained in a bean.
Here's an excerpt of my bean:
public class LogManageBean implements ValueChangeListener, ActionListener {
private List test;

public void SearchLog(){
// populates the test list
}
public List getTestList(){
return test;
}

}

========

In my faces config file I've declared the bean like this:

  <managed-bean>
    <managed-bean-name>viewLog</managed-bean-name>
    <managed-bean-class>ams.LogManageBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
  </managed-bean>
=======

In my jsp page I want to display the contents of the list upon a button click.
      <h:commandButton value="Display" actionListener="#{viewLog.SearchLog}"  />
I don't know how can I display the contents of the list upon hitting the button. Basically how can I tie in the list to the <table> in jsp. The problem is that the button populates the list but how would the table know how to access the contents of the list.

Could someone please advise?

Thanks,
askhan
0
Comment
Question by:askhan1
2 Comments
 
LVL 4

Accepted Solution

by:
doraemon-nolife earned 500 total points
ID: 19728323
<h:dataTable value="#{logManageBean.test}"
              var="rowVar"
              border="1">
  <h:column>
    <h:outputText value="#{rowVar.col1Data}"/>
  </h:column>
  <h:column>
    <h:outputText value="#{rowVar.col2Data}"/>
  </h:column>
  ...
</h:dataTable>

Note:
===
col1Data and col2Data is the property field name in your test object.

You should write a getTest method, not getTestList, as the JSF would interpret the naming wrongly.

:)


0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 19885563
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup Zone:
Accept doraemon-nolife comment as answer.

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

mrcoffee365 Experts Exchange Cleanup Volunteer
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question