• Soujanya R 10
  • NEWBIE
  • 0 Points
  • Member since 2019

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

I am having a really weird issue with apex:InputFile.  I hide it until the user clicks on a button.  When I show it the first time and do a save, nothing goes back to the controller.  The value of my Blobs are null.

If I show it again and pick a file it works fine.

I added a text field to my dialog for testing purposes.  The text box always works.  The inputFile never works on the first call, but works fine after that.  Any suggestions on what I need to change

Here is the markup for my dialog with the Apex:InputFiles 

         <apex:outputPanel id="UploadPicture">
            <apex:outputPanel rendered="{!ShowUploadPicture}" layout="block" styleClass="SaveModal">
                     <div class="dmodal"  id="pictureModal" tabindex="-1" role="dialog" >
                        <div class="modal-dialog modal-dialog-centered"  role="document">
                            <div class="modal-content opaque">
                                
                                <div class="modal-header">
                                    <h1 class="modal-title">Upload Files</h1>
                                  </div>
  
                                <div class="modal-body">
                                    <apex:actionRegion >
                                        <apex:inputText value="{!DummyText}" label="Dummy Text"/>
                                        <apex:outputPanel layout="block" styleclass="panel panel-default" style="margin:20px;" >
                                            <apex:outputpanel layout="block" styleclass="panel-body">
                                                <div class="col-xs-12 col-sm-12 col-md-12 text-center">
                                                    <H4>Inside Store Photo</H4>
                                                    <div class="row" style="height:120px;">
                                                        <apex:outputPanel styleclass="glyphicon glyphicon-ok-circle upOk" html-aria-hidden="true" rendered="{!NOT(ISNULL(InsideStorePhoto.Id))}"></apex:outputPanel>         
                                                        <apex:image url="{!URLFOR($Resource.rvie_img_place)}" height="100" alt="" rendered="{!ISNULL(InsideStorePhoto.Id)}" />
                                                        <apex:image url="{!URLFOR($Action.Attachment.Download, InsideStorePhoto.Id)}" height="100"
                                                                    html-onerror="this.src='{!$Resource.no_preview}'" alt="Preview not supported" rendered="{!NOT(ISNULL(InsideStorePhoto.Id))}"
                                                                    onclick="window.open('{!URLFOR($Action.Attachment.Download, InsideStorePhoto.Id)}','_blank','toolbar=yes, scrollbars=yes, resizable=yes');" />
                                                    </div>
                                                    <apex:outputPanel layout="block" styleclass="row" >
                                                        <label class="btn btn-default btn-file">
                                                             Select a Picture<apex:inputfile value="{!IBody}" contentType="image" filename="{!InsideStoreBody.Name}" onchange="previewFileAll(this)" style="display:none;"/><!----->
                                                           <br/>{!InsideStoreBody.Name}
                                                        </label>
                                                    </apex:outputPanel>
                                                </div>
                                            </apex:outputpanel>
                                        </apex:outputPanel>
                                        <apex:outputPanel layout="block" styleclass="panel panel-default" style="margin:20px;" >
                                            <apex:outputpanel layout="block" styleclass="panel-body">
                                                <div class="col-xs-12 col-sm-12 col-md-12 text-center">
                                                    <H4>Overall Photo</H4>
                                                    <div class="row" style="height:120px;">
                                                        <apex:outputPanel styleclass="glyphicon glyphicon-ok-circle upOk" html-aria-hidden="true" rendered="{!NOT(ISNULL(OverallPhoto.Id))}"></apex:outputPanel>         
                                                        <apex:image url="{!URLFOR($Resource.rvie_img_place)}" height="100" alt="" rendered="{!ISNULL(OverallPhoto.Id)}" />
                                                        <apex:image url="{!URLFOR($Action.Attachment.Download, OverallPhoto.Id)}" height="100"
                                                                    html-onerror="this.src='{!$Resource.no_preview}'" alt="Preview not supported" rendered="{!NOT(ISNULL(OverallPhoto.Id))}"
                                                                    onclick="window.open('{!URLFOR($Action.Attachment.Download, OverallPhoto.Id)}','_blank','toolbar=yes, scrollbars=yes, resizable=yes');" />
                                                    </div>
                                                    <apex:outputPanel layout="block" styleclass="row" >
                                                        <label class="btn btn-default btn-file">
                                                            Select a Picture<apex:inputfile value="{!OBody}" contentType="image" filename="{!OverallBody.Name}" onchange="previewFileAll(this)" style="display:none;" /><!----->
                                                            <br/>{!OverallBody.Name}
                                                       </label>
                                                    </apex:outputPanel>
                                                </div>
                                            </apex:outputpanel>
                                        </apex:outputPanel>
                                        <apex:outputPanel layout="block" styleclass="panel panel-default" style="margin:20px;" >
                                            <apex:outputpanel layout="block" styleclass="panel-body">
                                                <div class="col-xs-12 col-sm-12 col-md-12 text-center">
                                                     <H4>Restroom Photo</H4>
                                                   <div class="row" style="height:120px;">
                                                        <apex:outputPanel styleclass="glyphicon glyphicon-ok-circle upOk" html-aria-hidden="true" rendered="{!NOT(ISNULL(RestroomPhoto.Id))}"></apex:outputPanel>         
                                                        <apex:image url="{!URLFOR($Resource.rvie_img_place)}" height="100" alt="" rendered="{!ISNULL(RestroomPhoto.Id)}" />
                                                       <apex:image url="{!URLFOR($Action.Attachment.Download, RestroomPhoto.Id)}" height="100"
                                                                   html-onerror="this.src='{!$Resource.no_preview}'" alt="Preview not supported" rendered="{!NOT(ISNULL(RestroomPhoto.Id))}"
                                                                   onclick="window.open('{!URLFOR($Action.Attachment.Download, RestroomPhoto.Id)}','_blank','toolbar=yes, scrollbars=yes, resizable=yes');" />
                                                    </div>
                                                    <apex:outputPanel layout="block" styleclass="row" >
                                                        <label class="btn btn-default btn-file">
                                                            Select a Picture<apex:inputfile value="{!RBody}" contentType="image" filename="{!RestroomBody.Name}" onchange="previewFileAll(this)" style="display:none;"/><!----->
                                                            <br/>{!RestroomBody.Name}
                                                        </label>
                                                    </apex:outputPanel>
                                                </div>
                                            </apex:outputpanel>
                                        </apex:outputPanel>
                                    <!-->/div>
                                   <div class="modal-footer"-->
                                        <apex:commandbutton value="Save" action="{!SavePicture}" /> <!--reRender="UploadPicture, pbTable"/-->
                                        <apex:commandbutton immediate="true"  html-data-dismiss="modal" value="Cancel" action="{!HidePicture}"/> <!--reRender="UploadPicture, pbTable"/-->
                                    </apex:actionRegion>  
                                 </div>
 
                             </div>
                        </div>
                    </div>
             </apex:outputPanel>
        </apex:outputPanel>

Is there anything I need to do with my Blob Variables before my first call to make this work on the first time.
 

Hi all,

I am writing a test class. Wrapper class variable inside the method is not getting coverage. Bellow is my code. Bellow having my code. Fro line 22 to 30 didn't cover and 32 to 44 didn't cover.
public void GoToCart(){
    SearchRend=false;
    productRend=true;
    RendR = false; 

    // Insert Quote 
    QuoteVar = new Quote();
    QuoteProductList = new List<Quote_Product__c>();
    QuoteVar.Name=opp.Name;
    QuoteVar.OpportunityID=opp.id;
    QuoteVar.Status='Opened';
    insert QuoteVar;
    
    qid=QuoteVar.id;
    QuoteVar=[Select id, name from Quote where id=:qid];

    if(wrapPriceList != null){
    for(wrapPrice wrapPriceObj : wrapPriceList) {  //** Qoute Line Items section
        QuoteProduct = new Quote_product__c();
            if(wrapPriceObj.selected == true) {
            QuoteProduct.Quote__c=QuoteVar.id;
            QuoteProduct.Price_Detail__c=wrapPriceObj.pds.id;
            QuoteProduct.Description__c=wrapPriceObj.pds.partNo__r.part_description__c;
            QuoteProduct.Operating_Model__c=wrapPriceObj.pds.Operating_Model__c;
            QuoteProduct.Buying_Price__c=wrapPriceObj.pds.Buying_Price__c;
            QuoteProduct.Type__c=wrapPriceObj.pds.Type__c;
            QuoteProduct.MSRP__c=wrapPriceObj.pds.MSRP__c;
            QuoteProduct.Insurance__c=wrapPriceObj.pds.Insurance__c;
            QuoteProduct.Insurance_Validity__c='12';
            QuoteProductList.add(QuoteProduct);  
            }
    }}
    if(walitems != null){
    for(WalmartItems it1: walitems){
        QuoteProduct = new Quote_product__c();
          if(it1.selected == true){
           QuoteProduct.Quote__c=QuoteVar.id;
           QuoteProduct.Description__c = it1.item.name;
           //QuoteProduct.Walmart_ItemId__c = it1.item.itemId;
           QuoteProduct.Buying_price__c = it1.item.saleprice;
           QuoteProductList.add(QuoteProduct);
        }
    }
    }else if(searchitems != null){
   for(WalmartItems it1: searchitems){
        QuoteProduct = new Quote_product__c();
          if(it1.selected == true){
           QuoteProduct.Quote__c=QuoteVar.id;
           QuoteProduct.Description__c = it1.item.name;
           //QuoteProduct.Walmart_ItemId__c = it1.item.itemId;
           QuoteProduct.Buying_price__c = it1.item.saleprice;
           QuoteProductList.add(QuoteProduct);
        }
    }}
    insert QuoteProductList;
    
    for(Quote_product__c ql:QuoteProductList ){
         qpid.add(ql.id);
     }
    for(quote_product__c qp:[Select id, name,Buying_Price__c, Quantity__c, Discount__c, Insurance_Amount__c from Quote_product__C where id in :qpid]){
      if(qp.Buying_Price__c == null){
            continue;
      }else{
          NetAmount=NetAmount+qp.Buying_price__c;    
      }
    }
    
    selectedList = new List<price_details__c>();
    for(wrapPrice wrapPriceObj : wrapPriceList) {
            if(wrapPriceObj.selected == true) {
            selectedList.add(wrapPriceObj.pds);
            //NetAmount=NetAmount+wrapPriceObj.pds.Buying_price__c;
            }
    }
    
}