Favoriteシュ コウウ (DXCテクノロジー) asked in #TrailheadMay 15, 2017, 7:43 AMwhy the error?Attempt to de-reference a null object page test11 の式「{!selectGoods}」にエラーがあります: Class.testController.selectGoods: line 49, column 1public class testController { public List<T002__c> tDetailList { get;set; } //売上データ public T001__c t {get; set;} //商品リスト public List<M002__c> mList { get;set; } public testController() { //初期化 t= new T001__c(); mList = new List<M002__c>(); tDetailList = new List<T002__c>(); } //商品を取得 public static List<SelectOption> getSyouhinnOptions() { List<SelectOption> SyouhinnOptions = new List<SelectOption>(); SyouhinnOptions = syouhinnDAO.getSelectOptionList(); return SyouhinnOptions; } //受注商品情報を取得 public PageReference selectGoods() { Integer currentRow = Integer.valueof(ApexPages.currentPage().getParameters().get('theRow')); Integer currentRowNow = currentRow-1; system.debug('currentRow' + currentRow); String goodsCode = tDetailList[currentRowNow].Name; system.debug('goodsCode' + goodsCode); M002__c goods = syouhinnDAO.getSelectShouhinnByGoodsCode(goodsCode); system.debug('shuchu1' + goods.M00202__c ); system.debug('shuchu1' + goods.M00203__c ); system.debug('currentRowNow' + currentRowNow); tDetailList[currentRowNow].M002__r.M00202__c = goods.M00202__c; tDetailList[currentRowNow].M002__r.M00203__c = goods.M00203__c; tDetailList[currentRowNow].M002__r.M00204__c = goods.M00204__c; tDetailList[currentRowNow].M002__r.M00205__c = goods.M00205__c; // update tDetailList[currentRowNow]; return null; } //リストの追加 public PageReference add() { T002__c t= new T002__c(); Integer theRows = tDetailList.size(); Integer i = 0; for(i=0; i<theRows; i++){ system.debug(i); String goodsCode = tDetailList[i].Name; system.debug(goodsCode); if (goodsCode != null){ M002__c goods = syouhinnDAO.getSelectShouhinnByGoodsCode(goodsCode); tDetailList[i].M002__r.M00202__c = goods.M00202__c; tDetailList[i].M002__r.M00203__c = goods.M00203__c; tDetailList[i].M002__r.M00204__c = goods.M00204__c; tDetailList[i].M002__r.M00205__c = goods.M00205__c; } } tDetailList.add(t); return null; } }<apex:page controller="testController" docType="html-5.0"><html> <head> <div style="font-size: 32px;">受注入力</div> </head></html><apex:form > <apex:pageBlock > <apex:commandButton value="追加" rerender="theTable" action="{!add}" /> <apex:pageBlockTable value="{!tDetailList}" var="goods" id="theTable"> <apex:variable var="rowIndex" value="0"/> <apex:column id="rowindex"> <apex:facet name="header">項番</apex:facet> {!rowIndex} <apex:variable var="rowIndex" value="{!VALUE(rowIndex) + 1}" /> </apex:column> <apex:column id="name"> <apex:facet name="header">商品名</apex:facet> <apex:selectList id="selectedGoods" value="{!goods.Name}" size="1" > <apex:actionSupport event="onchange" action="{!selectGoods}" rerender="theTable" > <apex:param name="theRow" value="{!VALUE(rowIndex)-1 }"/> </apex:actionSupport> <apex:selectOption /> <apex:selectOptions value="{!SyouhinnOptions}" /> </apex:selectList> </apex:column> <apex:column id="code"> <apex:facet name="header">商品コード</apex:facet> {!goods.M002__r.Name} </apex:column> <apex:column id="price" > <apex:facet name="header">単価</apex:facet> {!goods.M002__r.M00203__c} </apex:column> <apex:column id="unit"> <apex:facet name="header">単位</apex:facet> {!goods.M002__r.M00204__c} </apex:column> <apex:column id="quantity"> <apex:facet name="header">売上数量</apex:facet> <apex:inputField value="{!goods.M002__r.M00207__c}" /> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form></apex:page> Show More1 answerSortSort by DateSort by Most HelpfulSort by DateNagendra Babu Pilli (Salesforce)May 15, 2017, 8:42 AMHi,Please provide add the code on line 49 as a separate part of your question, as no line numbers are present on forums community which helps us in identifying the error and for easy troubleshooting.Thanks,Nagendra.Add a commentWrite an answer...BoldItalicUnderlineStrikethroughBulleted ListNumbered ListAdd linkCode blockInsert imageAttach filesLink URLCancelSave0/9000Reply
Nagendra Babu Pilli (Salesforce)May 15, 2017, 8:42 AMHi,Please provide add the code on line 49 as a separate part of your question, as no line numbers are present on forums community which helps us in identifying the error and for easy troubleshooting.Thanks,Nagendra.