즐겨찾기シュ コウウ (DXCテクノロジー) 님이 #Trailhead에 질문했습니다2017년 5월 15일 오전 7:43why 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> 더 보기답변 1개정렬날짜별 정렬가장 유용한 항목별 정렬날짜별 정렬Nagendra Babu Pilli (Salesforce)2017년 5월 15일 오전 8:42Hi,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.댓글 추가답변을 작성하세요...굵은 글꼴기울인 글꼴밑줄취소선불릿 기호 목록번호가 지정된 목록링크 추가코드 블록이미지 삽입파일 첨부링크 URL취소저장0/9000답글 쓰기
Nagendra Babu Pilli (Salesforce)2017년 5월 15일 오전 8:42Hi,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.