function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jdogsailingjdogsailing 

No Help On: An internal server error has occurred

I have a simple component, SingletonResponseWidget, shown below that populates some input text widgets using a SurveyFragment bean passed in as an attribute. Without the assignTo= tag, this component works just fine except that the input text values are not stored in the SurveyFragment when they are entered. Following the Visualforce example, I tried creating a controller for this widget, the ResponseWidgetController also shown below.

 

When I attempt to assign the SurveyFragment attribute value to this controller's controllerValue; however, it throws an internal server error. I followed the instructions and posted the error to Salesforce support but they were not helpful. Evidently Support folks do not actually read any code, even if it caused their platform to barf.

 

Seems to me that code which compiles and is, essentially, copied from the manual should work. Any ideas?

Jeff

 

PS: Note that the component does not currently use any of the fields provided by the controller. It only tries to set the componentValue. If I could set the controller, I would then try to use the fields to see if their new values would get returned.

 

<apex:component controller="ResponseWidgetController">
    <apex:attribute name="fragment" description="This is the fragment for the component"
        type="SurveyFragment" required="required" assignTo="{!controllerValue}"/> 
    <apex:outputText >{!fragment.firstResponse.question}</apex:outputText><br />
    <em>{!fragment.sInstructions}</em><br />
    <apex:inputText value="{!fragment.firstResponse.score}" title="Score"/><br /> 
    <em>{!fragment.cInstructions}</em><br />
    <apex:inputTextarea value="{!fragment.firstResponse.comment}" cols="80" title="Comment"/><br /> 
</apex:component>

 

public class ResponseWidgetController {
   
    public SurveyFragment controllerValue {get; set;}
   
    public String getQuestion() {
        return controllerValue.firstResponse.question;
    }
   
    public Integer getScore() {
        return controllerValue.firstResponse.score;
    }
   
    public void setScore(Integer score) {
        controllerValue.firstResponse.score = score;
    }
   
    public String getComment() {
        return controllerValue.firstResponse.comment;
    }
   
    public void setComment(String comment) {
        controllerValue.firstResponse.comment = comment;
    }
}

jwetzlerjwetzler
Can you cause it to happen again and post the new error code you get here?
jdogsailingjdogsailing
Error ID: 1379421946-1958 (1835799266)
jwetzlerjwetzler

So I don't really understand why you're getting the error you're getting, I can't yet reproduce this myself with what I think is pretty close to the code you have.

 

Can you look at what I have and see if you can figure out what's different about it, that mine would work and yours wouldn't?

 

This is my setup, my component is the same as yours without the instruction fields. 

 

public class response { public String Question {get; set;} public Integer score {get; set;} public String comment {get;set;} } public class SurveyFragment { public Response firstResponse {get;set;} } public class ResponseWidgetController { public SurveyFragment controllerValue {get; set;} public String getQuestion() { return controllerValue.firstResponse.question; } public Integer getScore() { return controllerValue.firstResponse.score; } public void setScore(Integer score) { controllerValue.firstResponse.score = score; } public String getComment() { return controllerValue.firstResponse.comment; } public void setComment(String comment) { controllerValue.firstResponse.comment = comment; } }

 

Here's my page that uses the component, it seems fine:

 

<apex:page controller="widgetcon"> <apex:form > <c:widget fragment="{!f}"/> <apex:commandButton value="click"/> </apex:form> </apex:page> public with sharing class widgetcon { public WidgetCon() { Response r = new Response(); r.question = 'question'; r.score = 1; r.comment = 'comment'; f = new SurveyFragment(); f.firstResponse = r; } public surveyfragment f {get; set;} }

 

 

 

 

jdogsailingjdogsailing

Interesting. When I duplicated your test page & controller and used my component and beans it works without error.

 

When called from my real page; however, it still throws the same internal server error. I will try working outward with test harnesses and see where the trail leads.

 

Jeff

jdogsailingjdogsailing

No luck. The SingletonResponseWidget is called from a ResponseWidget and that is called from my web page. When my test page calls ResponseWidget instead of SingletonResponseWidget that works fine too. But, when I embed the ResponseWidget in a page that mimics the datalist of my real page (the one that causes the server error), I get this error:

 

core.apexpages.el.adapters.ApexObjectValueELAdapter cannot be cast to common.apex.runtime.ApexValue

 

Here's my test page that throws the error:

 

 

<apex:page controller="widgetcon"> <apex:form > <apex:dataList var="obj" value="{!b.fragments}"> <c:ResponseWidget fragment="{!obj}"/> </apex:dataList> <apex:commandButton value="click"/> </apex:form> </apex:page>

 

 

Here's the test controller code, augmented by another layer of SurveyBean nesting:

 

 

public with sharing class widgetcon { public WidgetCon() { b = new SurveyBean(); b.fragments = new List<SurveyFragment>(); f = new SurveyFragment(); f.responses = new List<ResponseBean>(); f.singleton = true; ResponseBean r = new ResponseBean(); r.question = 'The question 0'; r.score = 1; r.comment = 'The comment 0'; f.firstResponse = r; b.fragments.add(f); f = new SurveyFragment(); f.responses = new List<ResponseBean>(); f.singleton = false; r = new ResponseBean(); r.question = 'The question 1'; r.score = 1; r.comment = 'The comment 1'; f.firstResponse = r; f.responses.add(r); r = new ResponseBean(); r.question = 'The question 2'; r.score = 1; r.comment = 'The comment 2'; f.responses.add(r); r = new ResponseBean(); r.question = 'The question 3'; r.score = 1; r.comment = 'The comment 3'; f.responses.add(r); b.fragments.add(f); } public SurveyFragment f {get; set;} public SurveyBean b {get; set;} }

 

 

Here's the component code:

 

 

ResponseWidget: <apex:component > <apex:attribute name="fragment" description="This is the fragment for the component" type="SurveyFragment" required="true" /> <apex:outputPanel rendered="{!fragment.singleton}"> <c:SingletonResponseWidget fragment="{!fragment}" /> </apex:outputPanel> <apex:outputPanel rendered="{!NOT(fragment.singleton)}"> <c:TableResponseWidget fragment="{!fragment}" /> </apex:outputPanel> </apex:component> SingletonResponseWidget: <apex:component controller="ResponseWidgetController"> <apex:attribute name="fragment" description="This is the fragment for the component" type="SurveyFragment" required="required" assignTo="{!controllerValue}"/> <apex:outputText >{!question}</apex:outputText><br /> <em>{!fragment.sInstructions}</em><br /> <apex:inputText value="{!score}" title="Score"/><br /> <em>{!fragment.cInstructions}</em><br /> <apex:inputTextarea value="{!comment}" cols="80" title="Comment"/><br /> </apex:component>

 

TableResponseWidget:

<apex:component >
<apex:attribute name="fragment" description="This is the fragment for the component"
type="SurveyFragment" required="true"/>
<em>{!fragment.sInstructions}</em> <br />
<apex:datatable value="{!fragment.responses}" var="obj"
styleClass="list" border="1">
<apex:column >
<apex:facet name="header">Questions</apex:facet>
<apex:outputText >{!obj.question}</apex:outputText>
</apex:column>
<apex:column >
<apex:facet name="header">N/A</apex:facet>
<apex:inputCheckbox value="{!obj.na}" title="N/A"/>
</apex:column>
<apex:column >
<apex:facet name="header">Score</apex:facet>
<apex:inputText value="{!obj.score}" title="Score" />
</apex:column>
</apex:datatable>
</apex:component>

 

 

 

jdogsailingjdogsailing

Ok, here is as close as I can get to pinning the tail on the donkey. With the above code, this fails as before:

 

<apex:page controller="widgetcon"> <apex:form > <apex:dataList var="obj" value="{!b.fragments}"> <c:ResponseWidget fragment="{!obj}"/> </apex:dataList> <apex:commandButton value="click"/> </apex:form> </apex:page>

 

... and, changing only the ResponseWidget fragment= as below, I get two copies of the TableResponseWidget correctly displayed:

 

 

<apex:page controller="widgetcon"> <apex:form > <apex:dataList var="obj" value="{!b.fragments}" > <c:ResponseWidget fragment="{!f}"/> </apex:dataList> <apex:commandButton value="click"/> </apex:form> </apex:page>

Note, in the controller, f is the second SurveyFragment and it contains three ResponseBeans. If I reverse those two initializations so that f is a singleton and has only one ResponseBean, it too displays 2 SingletonResponseWidgets correctly.

 

Finally, I added another controller, lf, which contains the list of SurveyFragments assigned to b.fragments. It has the same problems. From this I conclude that apex:dataList can iterate over the elements of a fragments list but it cannot bind 'obj' correctly to the ResponseWidget invocation.

 

I think this is a defect in the binding mechanism.

 

Jeff


 

jdogsailingjdogsailing

One more observation, the following (expanding the ResponseWidget) seems to work:

 

 

<apex:page controller="widgetcon"> <apex:form > <apex:dataList value="{!lf}" var="obj" id="theList"> <apex:outputPanel rendered="{!obj.singleton}"> <c:SingletonResponseWidget fragment="{!f}" /> </apex:outputPanel> <apex:outputPanel rendered="{!NOT(obj.singleton)}"> <c:TableResponseWidget fragment="{!obj}" /> </apex:outputPanel> </apex:dataList> <apex:commandButton value="click"/> </apex:form> </apex:page>

 Note that the SingletonResponseWidget is the only one with a controller. The fact that it works with '{!f}' and not with '{!obj}' is interesting. Also, it all works fine without the controller but submitted values are not returned to the calling controller.