You need to sign in to do that
Don't have an account?
Supper_Kent
How to show specific value of the element in the Arraylist in a Visualforce page?
Hi,
First, i added some values to the List, and then I return the entire list to visualforce page, my problem is that i can not show specific value of element in the visualforce page but only can show all the elements together once. Anybody has this experience, welcome.
Kent,
Is the index (of list element), which you want to display always static or does it dynamically change?
In case, it has to change dynamically, you need to set a value in the controller itself, to the index which you want to display. Basically, you need to define a getter!
on the other hand, if the index value to be shown is fixed, then you can use an "<apex:variable>" component to make a count of the iterations within the <apex:repeat> and display the value inside it only if the count comes equal to your index value!
<apex:variable value="{!0}" var="temp"/>
<apex:repeat value="{!list}" var="val">
<apex:outputText value="{!val}" rendered="{!IF(temp==index,true,false)}"/>
<apex:variable var="temp" value="{!(temp)+1}"/>
</apex:repeat>
Cool_D
All Answers
Well, not sure how you are rendering the list on your VF page:(
Basically, you need to iterate through your list to show each value seperately! See below-
<apex:repeat value="{!list}" var="val">
{!val}
</apex:repeat>
So, here each value will be shown seperately and you can set the style/display the way you want to!!
Cool_D
Kent,
Is the index (of list element), which you want to display always static or does it dynamically change?
In case, it has to change dynamically, you need to set a value in the controller itself, to the index which you want to display. Basically, you need to define a getter!
on the other hand, if the index value to be shown is fixed, then you can use an "<apex:variable>" component to make a count of the iterations within the <apex:repeat> and display the value inside it only if the count comes equal to your index value!
<apex:variable value="{!0}" var="temp"/>
<apex:repeat value="{!list}" var="val">
<apex:outputText value="{!val}" rendered="{!IF(temp==index,true,false)}"/>
<apex:variable var="temp" value="{!(temp)+1}"/>
</apex:repeat>
Cool_D
Hi bro,
This is a very smart way, thanks for your help. So, we can not use the index to get the value directly, can we? Anyway, this solved my problem.:smileyvery-happy: