You need to sign in to do that
Don't have an account?
sfdc18
How to render <apex:outputPanel> in visualforce page till count becomes 0
Hi,
I have Integer Count in my controller.
The value of this count is dynamically rendered through query.
Count = [Select Count() from User where UserRole.Name =: 'Manager'];
How to render <apex:outputPanel> in visualforce page till count becomes 0.
Also the outputPanel should be displayed only once for one user.
Thanks
I have Integer Count in my controller.
The value of this count is dynamically rendered through query.
Count = [Select Count() from User where UserRole.Name =: 'Manager'];
How to render <apex:outputPanel> in visualforce page till count becomes 0.
Also the outputPanel should be displayed only once for one user.
Thanks
You need to create a property , then assign the count value to the property.
you can use rended attribute of output panel.
<apex:outputPanel rendered = "{! count !=0 && $User.name=='text'}">
Thanks,
Sagarika
Where to decrement that count and how to dynamically assign User Name here $User.name=='text'.
Thanks
Regarding decrementing the counter , i do not understand the requrement clearly , kindly Elaborate
and for the dynamicly assign user, you can fetch the user , whose role is "Manager", assign it to a property and access that in vf page
Thanks,
Sagarika
If you check this query
Integer Count = [Select Count() from User where UserRole.Name =: 'Manager'];
Count holds the integer count of no of users in the organisation.
I have to display the ouputPanel for each and every user in the org whose role is manager.
I can't assign name of the user directly using text in rendered attribute, since I dont know the names of users in the org where this page will be used.
I want dynamic way where I can render the outputPanel for each and every user in the above mentioned count.
The purpose behind the decrement is, it should cover all the users in the count.
Thanks
If you have count in your controller then you can simply show the outputpanel if count is not 0 or greter than 0...
Refer below code for the same..
<apex:outputPanel rendered = "{! If(count >0,true, false )">
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
<apex:outputPanel rendered = "{! If(count >0,true, false )"> this will display outputPanel only once, if the condition count > 0 satisfies.
But,If you refer my earlier comments, then how to display this outputPanel for all the users.(users counted in our count variable).
Thanks.
Can you elaborate more , what do you mean by when you say for all users..how it should be...
there is only one outputpanel and which you want to render based on count value if that is not 0..then what does it mean by for all users which is in count??
Thanks,
Sandeep
If you check this query
Integer Count = [Select Count() from User where UserRole.Name =: 'Manager'];
Count holds the integer count of no of users in the organisation.
I have to display the ouputPanel for each and every user in the org whose role is manager.
I can't assign name of the user directly using text in rendered attribute, since I dont know the names of users in the org where this page will be used.
I want dynamic way where I can render the outputPanel for each and every user separately in the above mentioned count.
i.e. OutputPanel will repeat for all users dynamically
Thanks
But at a time you will be logged in as one user only and if that user.role is manager then this outputpanel should be visible to them..This is what you need right ?
Thanks,
Sandeep
One question I have..how many outputpanel you have in your org....suppose there are 15 user those having role as manager...then you will render 15 outputpanels which will be related to those users ? It means you have outputpanels for each users and those you will render if user.role is manager..
Thanks
I have only one ouputPanel.
I have reapeatedly display this outputPanel for all the users with role equal to manager.
for eg. If there are 10 users with role = manager in the org, then display this outputPanel for 10 times(1 time for each user).
Thanks
Then it is very easy to simply display the panel 10 time if count is 10...you can take a list<Integer> lstCount and then you can simply add elements in this list and use this list in repeat and then you will be able to show 10 panels..
list<Id> lstUser = new list<Id>();
for(User objUser : [select Id from user where UserRole.Name =: 'Manager' ])
{
lstUser .add(objUser.Id);
}
in Page:
<Apex:repeat value="{!lstUser }" var="use">
<apex:outputpanel>
</apex:outputpanel
</apex:repeat>
please refer above code doe reference , this will do what you are looking for..pleae check and let me know if I am missing anything or my understanding is wrong for your need..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer