• anand rastogi
  • NEWBIE
  • 0 Points
  • Member since 2013

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

hi,

i have create an object named Post_Requirement__c. it contains various picklist with options which will be used for inserting data. I have also created a visualforce page of the same functionality. The problem is i m not getting values of the picklist options in the viusalforce page. Also please note that i do not want to fetch any record. i just want to insert record into database using these values.

 

 

Followiing is the code of VF page  

 

<apex:page standardcontroller="Post_Requirements__c"  tabStyle="Post_Requirements__c" sidebar="false" showHeader="false">
<style type="text/css">
  .button1{background-color:#FFFFFF;font-weight:bold;color:#FFFFFF;}
  .left_panel{width:50%; margin:0 10px 0 0; float:left;}
  .right_panel{margin: 0 0 0 225px;}
  .right_panel .Custom9Block {width:50% !important; float:left !important;}
  .right_panel .Custom9Block .tertiaryPalette {boder:0; border-top:2px solid #94B9D1!important; color:#27282E!important;}
   body .right_panel .Custom9Block .bPageBlock .pbBody .pbSubheader .hideListButton {background:url() no-repeat scroll 0 -11px transparent !important;}
   body .right_panel .Custom9Block .bPageBlock .pbBody .pbSubheader .showListButton {background:url() no-repeat scroll 1px -1px transparent !important;}
      
  </style>
<div style="float:left; width:100%">
 
      <div class="left_panel">
          <apex:image value="{!$Resource.background}"></apex:image>
      </div>
      <div class="right_panel">
       <body bgcolor="blue">

     <apex:form >
                   <center>
   <font size="5" face="Monotype Corsiva" color="blue"><i>Welcome To Real Estate</i></font>
   </center>
   <br/>
   <br/>
     <br/>
<center>
   <font size="3" face="Monotype Corsiva" color="blue"><i>Post Your Requirement Here</i></font>
   </center>

            <table align="center" cellpadding="15" >
        <tr><td>Select Property Type :-</td>
            <td><apex:selectList value="{!Post_Requirements__c.Property_Type__c}" multiselect="false" size="1" required="true">
            <apex:selectOptions value="{!Post_Requirements__c.Property_Type__c}"/>
        </apex:selectList></td>
        </tr>
        <tr><td>Select Transaction Type:-</td>
            <td><apex:selectList value="{!Post_Requirements__c.Transaction_Type__c}" multiselect="false" size="1" required="true">
            <apex:selectOptions value="{!Post_Requirements__c.Transaction_Type__c}"/>
        </apex:selectList></td>
        </tr>
        <tr><td>Select Purchase Type:-</td>
            <td><apex:selectList value="{!Post_Requirements__c.Purchase_Type__c}" multiselect="false" size="1" required="true">
            <apex:selectOptions value="{!Post_Requirements__c.Purchase_Type__c}"/>
        </apex:selectList></td>
        </tr>
       <tr><td>Select Country Type:-</td>
            <td><apex:selectList value="{!Post_Requirements__c.Country__c}" multiselect="false" size="1" required="true">
            <apex:selectOptions value="{!Post_Requirements__c.Country__c}"/>
        </apex:selectList></td>
        </tr>
       <tr><td>Select City Type:-</td>
            <td><apex:selectList value="{!Post_Requirements__c.City__c}" multiselect="false" size="1" required="true">
            <apex:selectOptions value="{!Post_Requirements__c.City__c}"/>
        </apex:selectList></td>
        </tr>
       
        <tr><td>Select Budget Type:-</td>
            <td><apex:selectList value="{!Post_Requirements__c.Budget__c}" multiselect="false" size="1" required="true">
            <apex:selectOptions value="{!Post_Requirements__c.Budget__c}"/>
        </apex:selectList></td>
        </tr>


    </table>
    <br></br>
 <center>     <apex:commandButton styleclass="button1" value="Post Requirement" action="{!Save}" rerender="out" style="color:white;background:red;"/></center>
   
                       </apex:form></body></div>
          </div>
         
<table align="center">
<tr><td><i><b> <font color="red">Copyright © 2000-2012 RealEstate.com, inc. All rights reserved</font></b></i></td></tr>
</table>            
</apex:page>

Hi,

 

I am pretty new to Visualforce... I have the developer guide printed out in front of me trying to get my head wrapped around everything.

 

I currently have a custom controller that pulls a bunch of records from a custom object called Milestone__c based on the Opp ID of the current page.That works fine, I am just trying to get a save button to work so I/whoever can update the milestones quickly. I used the "An Approach to Inline Editting" tutorial and that works fine but now am thinking that a save button on the list would be better. Can anyone help me with this?

 

I really want to make the Status field a drop down where you can edit multiple then save. Right now it is a drop down but I can't figure out the Save function, I've tried a bunch of different approaches based on posts but have been unsuccessful.

 

VF:

 

<apex:page Controller="TestMilestones" showHeader="false" > <apex:form > <apex:pageBlock title="Milestones" > <apex:pageBlockButtons location="top"> <apex:commandButton action="{!save}" value="save" id="saveButton"/> </apex:pageBlockButtons> <apex:outputPanel id="projectList"> <table> <tr> <th style="width:25px; "> </th> <th style="width:25px; "> </th> <th style="width:150px; ">Name</th> <th style="width:68px; ">Status</th> <th style="width:30px; ">Duration</th> </tr> <apex:repeat value="{!projects}" var="p"> <tr style="height:22px"> <apex:outputPanel id="editRow" layout="none" rendered="{!p.Id == editProject.Id}"> <td><apex:commandLink action="{!cancelEdit}" rerender="projectList">Cancel</apex:commandLink></td> <td><apex:commandLink action="{!saveEdit}" rerender="projectList">Save</apex:commandLink></td> <td><apex:inputField rendered="{!p.Id == editProject.Id}" value="{!editProject.Name}"/></td> <td><apex:inputField rendered="{!p.Id == editProject.Id}" value="{!editProject.Status__c}"/></td> <td><apex:inputField rendered="{!p.Id == editProject.Id}" value="{!editProject.Duration__c}"/></td> </apex:outputPanel> <apex:outputPanel id="viewRow" layout="none" rendered="{!p.Id != editProject.Id}"> <td style="font-style:italic; font-size:10px"> <apex:commandLink action="{!del}" onclick="return confirm('Are you sure you want to delete this project?')">Del <apex:param name="delid" value="{!p.Id}"/> </apex:commandLink> </td> <td style="font-style:italic"> <apex:commandLink action="{!edit}" rerender="projectList">Edit <apex:param name="editid" value="{!p.Id}"/> </apex:commandLink> </td> <td>{!p.Name}</td> <td style="background-color:yellow"><apex:inputField id="stat" value="{!p.Status__c}" /></td> <td><CENTER>{!p.Duration__c}</CENTER></td> </apex:outputPanel> </tr> </apex:repeat> </table> <CENTER><STRONG>**Click on status to update it</STRONG></CENTER> </apex:outputPanel> </apex:pageBlock> </apex:page>

 

 Controller:

 

public class TestMilestones { public TestMilestones(ApexPages.StandardController controller) { } public Milestone__c newProject { get; set; } public Milestone__c editProject { get; set; } public TestMilestones() { newProject = new Milestone__c(); } public Milestone__c[] getProjects() { return [SELECT Name, Duration__c, Status__c FROM Milestone__c WHERE Opportunity__c = :ApexPages.currentPage().getParameters().get('id') ORDER BY CreatedDate DESC]; } public String getParam(String name) { return ApexPages.currentPage().getParameters().get(name); } public PageReference add() { try { INSERT newProject; // if successful, reset the new project for the next entry newProject = new Milestone__c(); } catch (Exception e) { ApexPages.addMessages(e); } return null; } public PageReference del() { try { String delid = getParam('delid'); Milestone__c project = [SELECT Id FROM Milestone__c WHERE ID=:delid]; DELETE project; } catch (Exception e) { ApexPages.addMessages(e); } return null; } public PageReference edit() { String editid = getParam('editid'); editProject = [SELECT Name, Duration__c, Status__c FROM Milestone__c WHERE Id=:editid]; return null; } public PageReference cancelEdit() { editProject = null; return null; } public PageReference saveEdit() { try { UPDATE editProject; editProject = null; } catch (Exception e) { ApexPages.addMessages(e); } return null; } }

 

 Any help would be greatly appreciated