1

On my visualforce page I have a Student Name field with an Add Button. Whenever I enter a value and click Add It should update the name in the table below along with the created date and Student number which would be an auto-number field.

So far this is what I have done:

Wrapper Class:

public with Sharing class WrapperClass{
 public class StudentRosterData{
 public Date DateCreated { get; set; }
 public String Name { get; set; }
 public Integer StudentNumber { get; set; }

 }
 public StudentRosterData studentData{get; set;}

public WrapperClass(){
 studentData = new StudentRosterData();

 }
}

Visualforce Page:

<apex:page controller="StudentRosterController">
    <apex:form >
Student Name: <apex:inputText value="{!Names}" />
<apex:commandButton value="Add" action="{!AddNames}"/>
<table border="0">

 <tr> 
     <td><b>Name</b></td>
     <td><b> Entered Date</b> </td>
    </tr>
<apex:repeat value="{!wrapper.studentData}" var="stu">
<tr> 
    <td> <apex:outputText value="{!stu.Name}"/></td>
    <td> <apex:outputText value="{!stu.StudentNumber}"/></td>
    <td> <apex:outputText value="{!stu.DateCreated}"/></td></tr>
</apex:repeat>
</table>
    </apex:form>
</apex:page>

StudentRosterCOntroller:

    public class StudentRosterController{

        public String Names { get; set; }


        public WrapperClass wrapper{get; set;}

        public voidAddNames() {
        WrapperClass.StudentRosterData addstudent = new WrapperClass.StudentRosterData();

           wrapper.studentData.Name = Names;
           wrapper.studentData.DateCreated = Date.today();   

        }


}

Please guide me on how can I achieve this.

1 Answer 1

1

Use the code found at https://developer.salesforce.com/page/Visualforce_DynamicEditPage to show you how to rerender page elements.

I won't write your code for you, but you seem to have a decent start at that. You'll find what you want at that page.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .