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
MMA_FORCEMMA_FORCE 

For Loop Please...

HI:

   I have a variable Public String Terms;

I have about 4 Terms to a grade. So 9.1, 9.2, 9.3,9.4 and then 10.1, 10.2, 10.3 etc until 12th grade.

 

I wrote this for loop because I need to render outpanels by the Term

 

 

for(Integer z=1;z<5;z++){ for(Integer ii=9;ii<13;ii++){ Terms = Terms+ii+'.'+z; System.Debug('zTerms ' + Terms ); } }

 Of course I do not know if this is correct I do see the debug doing it:

9.110.111.112.19.210.211.212.29.310.311.312.39.410.411.412.4

 

 But I need to break it for each Term...

So in my VF Page I can say:

<apex:outputPanel rendered="{!Terms='9.2'}">

Is this correct?

Thanks

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Is there any particular reason why you require a wrapper class?  A list of strings would do the trick, as follows:

 

 

public List<String> getGrades()
{
List<String>grades=new List<String>();
for(Integer z=1;z<5;z++)
{
for(Integer ii=9;ii<13;ii++)
{
grades.add(ii+'.'+z);
}
}
System.Debug('grades ' + grades );

return grades;
}

 

I've used this in a page as follows:

 

 

<apex:repeat value="{!grades}" var="grade">
<apex:outputText value="Special {!grade}" rendered="{!grade=='9.4'}"/>
<apex:outputText value="{!grade}" rendered="{!NOT(grade=='9.4')}"/>

<br/>
</apex:repeat>

 

 And I get the following results:

 

 

9.1
10.1
11.1
12.1
9.2
10.2
11.2
12.2
9.3
10.3
11.3
12.3
Special 9.4
10.4
11.4
12.4

 

Does this cover what you are looking for?

 

 

 

 

 

Message Edited by bob_buzzard on 03-23-2010 02:17 AM

All Answers

imuinoimuino

First of all i would change the order of the for anidation, so it gets ordered by the integer part of the term

Apart from that it is doing what you want, just add a space on system.debug end to separate each term from another

MMA_FORCEMMA_FORCE

Thank you for the quick response... hmm How do I add a space in the System Debug... But in my VF Page:

This does not work:

 

<apex:outputPanel rendered="{!Terms='9.1'}">

 ??

Like how would I separate it to call it in my VF Page?

9.19.29.39.410.110.210.310.411.111.211.311.412.112.212.312.49.19.29.39.410.110.210.310.411.111.211.311.412.112.212.312.4

 

 

 

imuinoimuino

Do this to add an space to the output:

System.debug(Terms + ' ');

 

The thing is as you are doing it right now Terms will always end up with the same value which is 12.4 i guess

I think you'll need an List of String to do what you want

 

 

MMA_FORCEMMA_FORCE

Ok So I changed it and placed it in a wrapper class...

 

Termsx = new List<ARHolderT>(); for(Integer ii=9;ii<13;ii++){ for(Integer z=1;z<5;z++){ ARHolderT myObject = new ARHolderT(); myObject.Terms = myObject.Terms+ii+'.'+z; System.Debug('zzterm ' + myObject.Terms); Termsx.add(myObject); } }

 Now... In my VF Page I did:

 

<apex:variable value="{!Termsx}" var="h"/> <apex:outputPanel rendered="{!h.Terms='9.1'}">

 I get this error:

Unknown property 'VisualforceArrayList.Terms'????

Thanks


 

 

 

imuinoimuino
There isnt h.Terms h is a single object on the list thats why you cant access Term just write h
MMA_FORCEMMA_FORCE

I do appricate all your help... Can you give me an example of it because I tried this and it did not work:

 

<apex:variable value="{!Termsx}" var="h"/> <apex:outputPanel rendered="{!h}"> OR <apex:variable value="{!Termsx}" var="h"/> <apex:outputPanel rendered="{!h}='9.1'">

 

 

 

bob_buzzardbob_buzzard

Is there any particular reason why you require a wrapper class?  A list of strings would do the trick, as follows:

 

 

public List<String> getGrades()
{
List<String>grades=new List<String>();
for(Integer z=1;z<5;z++)
{
for(Integer ii=9;ii<13;ii++)
{
grades.add(ii+'.'+z);
}
}
System.Debug('grades ' + grades );

return grades;
}

 

I've used this in a page as follows:

 

 

<apex:repeat value="{!grades}" var="grade">
<apex:outputText value="Special {!grade}" rendered="{!grade=='9.4'}"/>
<apex:outputText value="{!grade}" rendered="{!NOT(grade=='9.4')}"/>

<br/>
</apex:repeat>

 

 And I get the following results:

 

 

9.1
10.1
11.1
12.1
9.2
10.2
11.2
12.2
9.3
10.3
11.3
12.3
Special 9.4
10.4
11.4
12.4

 

Does this cover what you are looking for?

 

 

 

 

 

Message Edited by bob_buzzard on 03-23-2010 02:17 AM
This was selected as the best answer