• mpring
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Hi,
I have a bunch of custom components inside an apex:tabPanel. Each component is tasked with creating or editing an sObject passed to the comp through a wrapper class from my main page controller. My problem is that when I use a select list with an action support to update the sObject within the controller using values derived from the selectList selection, the values are set with no problem, but when I change the values from inputFields within the components the values don't bind when I hit my save button. It's like the values are never making it to the sObject. Any suggestions? 

Here's my Controller code:
public with sharing class wizard_Labor_comp_ctrlr {

//Properties

public ComponentConnector myConnector  {get; set;}

public void setMyConnector(ComponentConnector newConn){
myConnector = newConn;
}

public ComponentConnector getMyConnector(){
return myConnector;
}

public string selLaborItemId    {get; set;}
public list<SelectOption> laborOpts   {get; set;}
private map<string, Resource_Group__c> laborMap  {get; set;}
public boolean readyToSave     {get; set;}



public Proposal_Line_Item__c myLineItem  {get{
            if(myConnector == null){
             myLineItem = new Proposal_Line_Item__c();
             myLineItem.Invoice_Name__c = 'My Connector does not exist';
             return myLineItem;
            }
            else {
             if(myConnector.selectedLineItem == null){
              myLineItem = new Proposal_Line_Item__c();
              myLineItem.Invoice_Name__c = 'Selected Line Item does not exist';
              return myLineItem;
             }
             else return myConnector.selectedLineItem;
          
            }
           }
           set;}
          
public string invoiceName {get; set;}
public string quantity   {get; set;}
public string testStr      {get; set;}

//UNIVERSAL METHODS
public wizard_Labor_comp_ctrlr(){
loadSelectOptionItems();
readyToSave = false;
testStr = 'testing:';
}

public pageReference saveLineItem(){

testStr += quantity;
//myLineItem.quantity__c = decimal.valueOf(quantity);
myLineItem.Invoice_Name__c = invoiceName;

if(readyToSave){
  myConnector.saveLineItem(true);
}

return null;
}

public pageReference clearLineItem(){

myConnector.clearLineItem();

return null;
}


// SPECIFIC METHODS
private void loadSelectOptionItems(){
list<Resource_Group__c> laborList = [SELECT id, resource_group_name__c, invoice_name__c, Cost__c, Resale_Per_Day__c, Resale_Per_Hour__c, Unit_of_Measure__c, IBS_resource_Group_ID__c FROM Resource_Group__c WHERE resource_Type__c = 'Labor'];

laborOpts = new list<SelectOption>();
laborMap = new map<string, Resource_Group__c>();

for(Resource_Group__c labor : laborList){
  laborOpts.add(new SelectOption(labor.Id, labor.invoice_Name__c));
  laborMap.put(labor.Id, labor);
}
}

public void updateLaborItem(){
if(selLaborItemId != null){
  Resource_Group__c tempLabor = laborMap.get(selLaborItemId);
  string uOfM = tempLabor.Unit_of_Measure__c;
 
 
  if(myLineItem.Quantity__c == null) myLineItem.Quantity__c = 0;
 
  myLineItem.Invoice_Name__c = tempLabor.Invoice_Name__c;
  myLineItem.Cost__c = tempLabor.Cost__c;
  myLineItem.Unit_of_Measure__c = uOfM;
 
  if(uOfM == 'Hourly') myLineItem.Unit_Price__c= tempLabor.Resale_Per_Hour__c;
  else if(uOfM == 'Daily') myLineItem.Unit_Price__c = tempLabor.Resale_Per_Day__c;
  else myLineItem.Unit_Price__c = 1000000000;
 
  readyToSave = true;
}
}


}

And here's my component:
<apex:component controller="wizard_Labor_comp_ctrlr" allowDML="true" >
<apex:attribute name="LaborConnector" type="ComponentConnector" assignTo="{!MyConnector}" required="true" description="The Component Connector holding all Labor Line Items"/>



   <apex:outputpanel id="LaborTable" layout="block">
   
    <table style="width:100%; background-color:#F0F2CD;">
     <tr>
      <td>Labor Item:</td>
      <td>
       <apex:selectList id="laboroptions" value="{!selLaborItemId}" size="1" multiselect="false">
        <apex:selectOptions value="{!laborOpts}"/>
        <apex:actionSupport event="onchange" action="{!updateLaborItem}" rerender="LaborTable"/>
       </apex:selectList>
      </td>
     </tr>
     <tr>
      <td>Invoice Name: </td>
      <td>
       <apex:inputField id="LaborInvoiceNameBox" value="{!myLineItem.Invoice_Name__c}"/>
       <apex:inputText id="LaborInvoiceNameBox2" value="{!invoiceName}"/>
      </td>
     </tr>
     <tr>
      <td>Quantity:</td>
      <td>
       <apex:inputField id="LaborQuantityBox" style="width:50px" value="{!myLineItem.Quantity__c}"/>
       <apex:inputText id="LaborQuantityBox2" style="width:50px" value="{!quantity}"/>
      
      </td>
      <td>Unit Price:</td>
      <td>
       <apex:inputField id="LaborUnitPriceBox" style="width:75px" value="{!myLineItem.Unit_Price__c}"/>
      </td>
      <td>Unit of Measure:</td>
      <td>
       <apex:outputField id="LaborUnitOfMeasureBox"  value="{!myLineItem.Unit_of_Measure__c}"/>
      </td>
     </tr>
     <tr>
      <td>
       <apex:commandButton action="{!SaveLineItem}" disabled="{!NOT(readyToSave)}" value="Save" rerender="LaborTable,previewPane"/>
       <apex:commandButton action="{!ClearLineItem}" value="Clear" rerender="LaborTable"/>
      </td>
     </tr>
     <tr>
      <td>
       {!testStr}
      </td>
     </tr>
    </table>
  
  </apex:outputpanel>


</apex:component>

Lastly, the component within the main Page:
 
<apex:tabPanel id="clientTab" style="font-weight:bold; height:100%;"  switchType="client">
                                   <apex:tab id="LaborTab" label="Labor" name="Labor">
                                      <c:wizard_Labor_comp id="Labor" LaborConnector="{!sectionMap['Labor']}"/>
                                     </apex:tab>
                                 
          </apex:tabPanel>
  • December 23, 2013
  • Like
  • 0

Hi. I'm trying to create a portal user in a force.com site but I can't seem to get a userId returned from site.createpersonaccountportaluser.  No matter what I do nothing comes back. obnoxious. Has anyone else had this problem and/or solved it?

 

Here's the code where it's called. Student is a contact that was just created.

 

pUser = new User();
pUser.FirstName = student.firstName;
pUser.lastName = student.lastName;
pUser.Username = student.Email;
pUser.Email = student.Email;
pUser.CommunityNickname = student.firstName.left(1) + student.LastName;
pUser.Alias = student.firstName.left(1) + student.LastName.left(4);
pUser.emailencodingkey='UTF-8';
pUser.languagelocalekey='en_US';
String ownerId = site.getAdminId();

for(integer i=0; i < 10; i++){
userId = Site.createPersonAccountPortalUser(pUser, ownerId, currRecType, pwSelect);
if(userId != null)break;
}

  • October 31, 2013
  • Like
  • 0