I want to create a custom dashboard in Sales Force using visual force page. I want to get data from customs objects. For this I write a apex controller
<apex:page controller="Sample">
<apex:chart height="400" width="700" data="{!pweb}">
<apex:axis type="Numeric" position="left" fields="pweb2"
title="users Count" grid="true"/>
<apex:axis type="Category" position="bottom" fields="pweb1"
title="Week Days">
</apex:axis>
<apex:lineSeries axis="left" fill="true" xField="pweb1" yField="pweb2"
markerType="cross" markerSize="4" markerFill="#FF0000"/>
</apex:chart>
</apex:page>
and creating a chart using visualforce page:
<apex:page controller="Sample">
<apex:chart height="400" width="700" data="{!pweb}">
<apex:axis type="Numeric" position="left" fields="pweb2"
title="users Count" grid="true"/>
<apex:axis type="Category" position="bottom" fields="pweb1"
title="Week Days">
</apex:axis>
<apex:lineSeries axis="left" fill="true" xField="pweb1" yField="pweb2"
markerType="cross" markerSize="4" markerFill="#FF0000"/>
</apex:chart>
</apex:page>
It's not showing any error but after saving this, when I am clicking on preview button, its not showing anything. Could anyone please help me solve it?
Related
I'm trying to capture the selected tab in my controller. I have the below code and it works fine if I leave in the alert message in the script. Once I remove the alert it no longer seems to make the call to the controller. I'm only displaying one tab in the code snippet. I have 3 others defined.
<apex:page showheader="true" sidebar="true" controller="mycontroller">
<script>
function setActiveTabJava(value){
alert('here');
setActiveTab(value);
}
</script>
<apex:form >
<apex:actionFunction id="activeTab" name="setActiveTab" action="{!setTab}" reRender="">
<apex:param name="activeTab" assignTo="{!activeTab}" value=""/>
</apex:actionFunction>
</apex:form>
<apex:pageblock >
<apex:tabpanel selectedtab="Tab One" width="100%">
<apex:tab label="This is tab one" name="tabone" id="referralTab" ontabenter="setActTabJava('TAB1');">
<!-- other tab code-->
</apex:tab>
</apex:tabpanel>
</apex:pageblock>
I basically fixed this by using the value attribute on the tab panel. Since my controller only interested in know which tab was selected, and not when the tab was selected it worked. Basically:
<apex:tabpanel value="{!activeTab}">
<apex:tab name="tab1">...</apex:Tab>
So whenever a tab is changed, as long as you've specified a name attribute on the tab it will be accessible in your controller.
So sorry I no longer have that controller code to post but it was basically just a method that set a variable in the controller.
i want to display a report on a visualforce page. I found this snippet of code but it brings back a blank page. What piece am i missing to have it show the report data?
<apex:page showHeader="false" sidebar="false">
<apex:iframe src="/00OQ0000000Gdbm"/>
</apex:page>
I use code that looks like this to show a report in a Visualforce page. I've left out details that would get in the way:
<apex:page standardController="CustomOb__c" extensions="CobjController">
<apex:sectionHeader title="Manage Stuff"/>
<apex:form>
...
<apex:outputPanel id="MissingAttRpt" >
<apex:iframe src="/00O0000000AAJlV?isdtp=lt" scrolling="true" height="1588px" width="100%"/>
</apex:outputPanel>
...
</apex:form>
</apex:page>
The outputPanel is used so that the report can be re-rendered without refreshing the whole page.
Try getting rid of the showHeader and sidebar properties.
I am using following code to edit value of a record. And the code is working fine.
<rich:popupPanel header="Edit Company Region" id="editCompanyRegionPane"
domElementAttachment="parent" width="230" height="115">
<h:form>
<h:panelGrid columns="3" id="editCompanyRegionGrid">
<h:inputHidden value="#{CompanyAdminPageModel.editCompanyRegion.companyRegionId}"
id="editcompanyRegionId">
</h:inputHidden>
<h:message for="editcompanyRegionId" />
<h:column>
<h:outputText value="Name " />
<h:inputText value="#{CompanyAdminPageModel.editCompanyRegion.name}"
id="editCompanyRegionName">
</h:inputText>
<h:message for="editCompanyRegionName" />
</h:column>
</h:panelGrid>
<h:commandButton value="Update"
action="#{CompanyAdminPageModel.companyRegionUpdate}" render="table"
oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editCompanyRegionPane')}.hide();}" />
<h:commandButton value="Cancel"
onclick="#{rich:component('editCompanyRegionPane')}.hide(); return false;" />
</h:form>
</rich:popupPanel>
I want to show a message in the same page after updating the value in database. For example: when I will click on the update button then it will call method from Bean class and then update value in the DB and after closing the popup panel it will display a message (like: updated successfully) inside the same page.
Any help please.
I used follwoing java code:
public String updateUser(Long usrId, String firstName, String lastName,
String loginName, String emailAddr) {
AllCompanyDAO aDAO = new AllCompanyDAO();
FacesContext.getCurrentInstance().addMessage("test", new javax.faces.application.FacesMessage("Success"));
return aDAO.userUpdate(usrId, firstName, lastName, loginName, emailAddr);
}
and following jsf code:
<div class="content container">
<div style="padding-left:220px;">
To see the relationships between users and regions <a href="#{appPath}/app/insertion/userRegionInfo.faces" >click here</a> <br/>
<h:message for="test"></h:message>
</div>
</div>
At the end of companyRegionUpdate(), add :
A message
FacesContext.getCurrentInstance().addMessage("test", new FacesMessage("Success"));
Where test is the absolute reference to the <h:message> JSF component.
To your <h:commandButton> , add Ajax support
Such as
<h:commandButton value="Update" >
<a4j:support oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editCompanyRegionPane')}.hide();}" action="#{CompanyAdminPageModel.companyRegionUpdate}" event="onclick" reRender="test, table" />
</h:commandButton>
Where test is the absolute reference to the <h:message> JSF component.
Instead of adding ajax support to your <h:commandButton>, you could simply use <a4j:commandButton > component which has ajax support.
I used following code that solved my problem.
1. Used the following code in the companyRegionUpdate method in java.
FacesContext.getCurrentInstance().addMessage("test", new javax.faces.application.FacesMessage("Successful"));
Then used <h:messages /> inside my desired div. <h:messages /> is different than <h:message />. In my case <h:messages /> works.
That's it. :-)
<apex:pageBlock >
<apex:selectList id="fields" value="{! xxx}" multiselect="true" size="3" rendered="{! FieldRendering}">
<apex:selectOptions value="{!items}"/>
<!-- Search content -->
<apex:actionSupport event="onchange" reRender="srcResultPanel" action="{!find}"/>
</apex:selectList>
the select list is not rendering when FieldRendering attribute is true for sure but when i remove rendered attribute then its showing selectList and rerendering selectoptions properly can any one please tell how to fix it in starting FieldRendering attribute is false but after clicking a button it is true but it is not rendering after clicking the button why please explain and suggest how to fix it ??
The thing is if a tag is not meeting rendered criteria when the page loads it doesn't present in page so can't be rerendered. A viable solution is to wrap target tag in outputPanel and rerender It( the outputPanel tag).
I am trying to display information about Knowledge Articles on my page. One of the things I want to display is the most viewed article stat.
I have a Visualforce Apex component that looks like this:
<apex:component controller="Component_Query" access="global">
<apex:attribute name="QueryString" type="String" required="true" access="global" assignTo="{!queryString}"
description="A valid SOQL query in string form." />
<apex:variable value="{!results}" var="results"/>
<apex:componentBody />
</apex:component>
I have a Visualforce page that looks like this:
<apex:page >
<table id="articles">
<knowledge:articleList articleVar="article" sortBy="mostViewed" pageSize="5">
<tr>
<td>{!article.articlenumber}</td>
<td><a target="_parent" href="{!URLFOR($Action.KnowledgeArticle.View, article.id)}">{!article.title}</a></td>
<td>{!article.articletypelabel}</td>
<td>{!article.lastpublisheddate}</td>
<td>
<c:Query_component queryString="SELECT NormalizedScore FROM KnowledgeArticleViewStat WHERE ParentId = '{!article.id}'">
<apex:repeat value="{!results}" var="result">
</apex:repeat>
</c:Query_component>
</td>
</tr>
</knowledge:articleList>
</table>
</apex:page>
I put the Visualforce Page into a tab. When I view the page, all the information about the knowledge articles show up except for the information about the most viewed stat. How do I see this stat?
You forgot to add an output for the view stat. You must add an <apex:outputText> tag inside the repeat to show the value.
<apex:outputText>{!result.NormalizedScore}</apex:outputText>
This is what I ended up using in my Visualforce page:
<c:Query_component queryString="SELECT NormalizedScore, Id, ParentId FROM KnowledgeArticleViewStat WHERE Channel='Csp'">
<apex:variable value="{!results[articleid]}" var="result"/>
<span class="inlinesparkline">100, {!result}</span>
</c:Query_component>