• Shashwat
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hey !!!

Can anyone help me out solving this problem....

customised graphs, charts etc using VF ???
Hi,   
Can anyone help me out with this tast..??
I've created a table, it is retreving data successfully, but the code gives error when i try to save a new data.
Error--- Mandatory field missing.

The table successfully saves data if i place the input field outside the facet tag. but it places an input field in all rows and columns, which is not a proper way...

page---

<apex:page id="Page" controller="acc_add"> 
<apex:pageBlock title="Hello {!$User.FirstName}!"/>           
        <apex:form>
                <apex:sectionHeader title="Accounts through Table"/>
                <apex:pageblock>
                <apex:pageBlockSection title="Accounts">                
                <apex:dataTable value="{!Accounts}" var="account" width="100%" cellPadding="2" cellspacing="1" border="1">

                <apex:column>
                <apex:facet name="header">Name</apex:facet> 
                <apex:outputText value="{!account.name}"/>              
                <apex:facet name="footer">
                <apex:inputText value="{!Name}"></apex:inputText> 
        </apex:facet>
                </apex:column>

                <apex:column>
                <apex:facet name="header">BillingCity</apex:facet> 
                <apex:outputText value="{!account.BillingCity }"/>              
                <apex:facet name="footer">
                <apex:inputText value="{!BillingCity}" ></apex:inputText> 
                </apex:facet>
                </apex:column>                
                
                </apex:dataTable>                
                </apex:pageBlockSection>
                <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save Data to Account"/>
                </apex:pageBlockButtons>
                </apex:pageBlock>
        </apex:form>        
</apex:page>


controller--------


public class acc_add
{
public string name;
public string BillingCity;

List<Account> Accounts;
public List<Account> getAccounts()
{
if(Accounts == null) Accounts = [select Name, BillingCity from account];
return Accounts;
}

public String getName()
{return this.name;}

public void setName(String name)
{this.name = name;}

public String getBillingCity()
{return this.BillingCity;}

public void setBillingCity(String BillingCity)
{this.BillingCity = BillingCity;}

public pagereference save()
{
Account acc = new Account(Name=this.Name, BillingCity=this.BillingCity);
insert acc;
pagereference p;
p = Page.acc_table;
p.setRedirect(true);
return p;
}

}

___________________
Thanks in anticipation of a reply !!!

Thanks and regards
Shashwat Verma




Message Edited by Shashwat on 04-14-2008 04:05 AM

Message Edited by Shashwat on 04-14-2008 04:06 AM
Hey !!!

Can anyone help me out solving this problem....

customised graphs, charts etc using VF ???