Skip to main content
39 events
when toggle format what by license comment
Aug 27, 2015 at 14:54 comment added slim I'm afraid I don't have the permissions to give you access to the sandbox. How about just the cls and page files?
Aug 26, 2015 at 22:12 comment added Rob Sorry slim, I can't spot any other issues. If this is in a sandbox and you want me to have a look, I'd be happy to. Otherwise, you should be able to raise a bounty on this question soon.
Aug 26, 2015 at 21:33 comment added slim No, I did move the <apex:form> tag outside the repeater. I just forgot to include it in the code here.
Aug 26, 2015 at 19:31 comment added Rob It doesn't look like you've moved the <apex:form> tags to wrap the entire page (i.e. outside the <apex:repeat> tags) - this is what fixed the issue in my test.
Aug 26, 2015 at 19:30 comment added slim Added the code. I only added the rerender and the id index like you suggested in the last comment.
Aug 26, 2015 at 13:42 comment added Rob I'm afraid I didn't keep the test code. Please update your question with the latest code and I'll see if I can spot anything
Aug 26, 2015 at 13:34 comment added slim I added the rerender and the index id but I'm still not getting this to work. I cannot post in either of my textInput fields and when I check the debug logs, I can see the correct index being pulled (either 0 or 1) but the postAnswer value is always null. Do you mind sharing your code from your test?
Aug 25, 2015 at 8:28 comment added Rob I just recreated the issue in a sandbox, and wrapping everything in a single <apex:form> fixed it for me! Hopefully it will for you too. I did come across a different issue in the process - you need to rerender the <apex:variable var="questionIndex" value="{!0}" />. You can do this by giving it an ID, e.g. index, and changing the commandButton rerender to rerender="replies,index"
Aug 25, 2015 at 0:46 comment added slim Hi Rob, thanks for all your help on this. I did not get this resolved yet. I haven't worked on it since Friday. I will try wrapping the entire thing in <apex:form> currently, I have multiple form tags - could this be why?
Aug 24, 2015 at 11:33 comment added Rob Hi slim, were you able to resolve this? If not, try moving the <apex:form> tags so that they wrap your entire page. In the debug log above, is questionIndex = 0 correct - i.e. was it the first item that you clicked?
Aug 22, 2015 at 2:26 comment added slim I already have a rerender on the commandButton. Both commandButtons have the same action. Could that be interfering somehow? I'm just surprised that the second inputText works with the commandButton, but the first one doesn't.
Aug 22, 2015 at 2:14 comment added Rob Try adding a rerender attribute to the <apex:commandbutton />. It doesn't matter what it's rerendering, it's just necessary to have that attribute to make the parameters work properly. You could wrap the entire page contents in an <apex:outputpanel id="pageContents"></apex:outputPanel> and rerender that, if you like.
Aug 22, 2015 at 1:55 comment added slim postAnswer = null; questionIndex = 0; wrapperQuestions = {WrapperQuestions:[bestReply=Reply:{Id=90719000000CaSeAAK, CreatedDate=2015-08-10 18:15:23, CreatedById=005a0000009bsmSAAQ, CreatorName=Sean, QuestionId=906190000008OPQAA2, Body=test - this is a test best answer!, UpVotes=0, DownVotes=0, CreatorSmallPhotoUrl=c.cs24.content.force.com/profilephoto/005/T, CommunityId=09a19000000CahKAAS}, postAnswer=null, question=Question:{Id=906190000008OPQAA2, CreatorSmallPhotoUrl=c.cs24.content.force.com/profilephoto/005/T, CreatorFullPhotoUrl=c.cs24.content.force.com/profileph...
Aug 22, 2015 at 1:46 comment added Rob In that case I'd use System.debug() to check the values of wrapperQuestions and questionIndex inside saveReply().
Aug 22, 2015 at 1:29 comment added slim After adding the {!currentQuestion.postAnswer} code to the inpuText tag, I'm able to post to the second of the two reply fields, but not the first one.
Aug 22, 2015 at 1:02 comment added Rob You still need to change the value of the <apex:inputText /> element to {!currentQuestion.postAnswer} and questionIndex as another <apex:param> to the <apex:commandButton>
Aug 22, 2015 at 0:54 comment added slim Sorry - VF page updated now. I updated the Apex code but forgot the VF code.
Aug 22, 2015 at 0:45 comment added Rob Please take another look at the second half of my answer - you need to update your VF page.
Aug 22, 2015 at 0:42 comment added slim questionIndex is in the saveReply() function. You have to scroll to the bottom of the apex code portion. Just like you suggested: postAnswer = wrapperQuestions[questionIndex].postAnswer;
Aug 22, 2015 at 0:05 comment added Rob The VF code above does not include any mention of questionIndex.
Aug 22, 2015 at 0:02 comment added slim I code above is the most up-to-date version.
Aug 21, 2015 at 21:26 comment added Rob Please update your Visualforce code above to your latest version
Aug 21, 2015 at 19:33 comment added slim actually, it's not working for either reply inputText now.
Aug 21, 2015 at 19:24 comment added slim I tried postAnswer = wrapperQuestions[questionIndex].postAnswer;, but it's still giving me a null value for the postAnswer value. I have 2 of these inputText fields on my test page and I'm able to post the second reply, but always get a null value for the first one.
Aug 21, 2015 at 19:06 comment added Rob If you're taking the approach I suggested, this statement: wrapperQuestions[questionIndex].postAnswer = postAnswer; is the wrong way round. It should be postAnswer = wrapperQuestions[questionIndex].postAnswer;. If you're still having problems, please update all of the code above with the latest version.
Aug 21, 2015 at 18:33 comment added slim It seemed to work for the last reply box, but when I tested with the first one, I'm getting postAnswer as a null value. I've edited my post to include my save() function.
Aug 21, 2015 at 18:26 comment added slim That worked perfectly. Just note that the index has to start with 0.
Aug 21, 2015 at 18:26 vote accept slim
Aug 21, 2015 at 18:32
Aug 21, 2015 at 16:40 history edited Rob CC BY-SA 3.0
Changed wrapperQuestions[questionIndex]['postAnswer'] to wrapperQuestions[questionIndex].postAnswer
Aug 21, 2015 at 16:39 comment added Rob Sorry, that syntax was wrong. Try wrapperQuestions[questionIndex].postAnswer.
Aug 21, 2015 at 16:33 comment added slim Thanks! I think I'm getting closer now. I have added the index and the also a String 'postAnswer' to the wrapper class, but I'm not sure how to get the value using the index. I tried to access it like this: wrapperQuestions[questionIndex]['postAnswer'] but it is throwing an error. I know I'm getting the right questionIndex value (I used System.Debug('===postAnswer===' + questionIndex); and got the right value).
Aug 21, 2015 at 16:07 comment added Rob Cheers, updated answer!
Aug 21, 2015 at 16:06 history edited Rob CC BY-SA 3.0
Rewrite with new answer.
Aug 21, 2015 at 15:22 comment added slim This is just a snippet. I can post the entire thing so you can see what's happening if it helps.
Aug 21, 2015 at 15:16 comment added Rob Thanks for posting the controller, but it's still hard to tell what's going on - you aren't repeating anything in the code above.
Aug 21, 2015 at 15:13 comment added slim Added my controller, but it doesn't show much. I'm just using the button to debug what values are passed back. In my case I need to pass back the reply and the questionId - So I can post the reply into the database for the correct question.
Aug 21, 2015 at 15:09 comment added Rob Understood. In that case, you may need to change the type of postAnswer from a String to a list of Strings. It's hard to tell from the code above. Can you post more of the page (specifically the <apex:repeat>) and the controller please?
Aug 21, 2015 at 15:05 comment added slim Thanks Rob, but I think I was unclear. The inputText field is supposed to be empty and filled in by the user and then the value of this needs to be passed to the controller.
Aug 21, 2015 at 15:03 history answered Rob CC BY-SA 3.0