顯示具有 Visualforce 標籤的文章。 顯示所有文章
顯示具有 Visualforce 標籤的文章。 顯示所有文章

2017年3月22日 星期三

Apex VF 上使用output check

因為salesforce沒有outputcheck元件所以使用以下方式達到:

<apex:inputCheckbox value="{!@variable}" disabled="true"/>


2017年3月17日 星期五

How to create Date as input with Calendar in visualforce page

How to create Date as input with Calendar in visualforce page


-------- Vf page-------------
<apex:page controller="inputdate" >
<script>
function DynamicDatePicker(d_id)
{
    DatePicker.pickDate(false,d_id.id,false);
}
</script>
  <apex:form >

  <apex:inputText id="time" value="{!inputdate}" onfocus="DynamicDatePicker(this);" onchange="checkDateFormatt(this.id);" size="20" disabled="false" style="width:150px;"/>
  <apex:commandButton action="{!testdate}" value="Save" />
  </apex:form>

</apex:page>

--------------------- Apex Controller --------------------
public class inputdate
{
    public date inputdate{get;set;}


public void testdate()
{
    system.debug('@@@@@@@@@@@@@@'+inputdate);
}
}

2016年1月14日 星期四

Fix DML currently not allowed


DML currently not allowed

針對無法在constructor裡維護資料,有以下作法:
1. 於pageload結束後使用action
<apex:component controller="myController" Action="ModifyFunction">
2.於網頁load結束後使用javascipt call remote action修改資料

3,若是component則啟用allowDML屬性
<apex:component controller="myController" allowDML="true">

2015年11月12日 星期四

Salesforce VF 轉出Excel 時,避免欄位值因儲存格格式被修改


轉出Excel時,欄位值常因儲存格格式而被修改
此時可於前後加上&nbsp;便可避免此情形

Try to insert html blanks to the start and end of the string:
<apex:column headerValue="Account Number">                   
    <apex:outputText value="&nbsp;{!mt.Account_Number__c}&nbsp;" escape="false"/>
</apex:column>

 參考網址: Visualforce to Excel: Prevent long number from being displayed in Scientific Notation

2015年11月8日 星期日

Salesforce VF PDF Configuration

建立PDF相關設定

*Repeat Header
*Repeat Footer
*Page Counter
*WaterMark
*Repeat Grid Header & Footer
*Force to Break Page
*To avoid the 2nd page shift up

<apex:page showHeader="false" sidebar="false"  renderAs="PDF" standardStylesheets="false" applyBodyTag="false"
    standardController="Quote" extensions="ext_CustomQuotationPDF">
    <head>
<style type="text/css"  media="print">      
           @page {                                                     
               @top-center {                   
                   content: element(header);    
               }
           @bottom-left {
                   content: element(footer);
               }

               size: 210mm 297mm;
               margin: 15mm;
               margin-right:0mm;
             
               margin-top: 4.215cm;
               margin-bottom: 2.80cm;
               margin-left: 1.27cm;
               margin-right:1cm;
                     
           }                              

           div.header {                
                       padding: 10px;              
                       position: running(header);
                              
                       height: 50px;
                       margin-bottom: 5px;
                               
           }        
           div.footer {                
               display: block;             
               padding: 5px;               
               position: running(footer);  
               
               clear: both;
               margin-top: 15px;
                       
           }              
         
           .pagenumber:before {                
               content: counter(page);             
           }                       
           .pagecount:before {             
               content: counter(pages);            
           }                
         
           .labelcls
           {
               margin-left:400px; font-size:25px; font-weight:bold;
         
           }
         
           table {-fs-table-paginate: paginate;}
         
</style>
    </head>
    <body>
<div class="header" width="100%">
                       Header Contents
        </div> 
   
    <div class="footer" style="font-size:16px;">
         Footer Contents      
         <center>
             Page <span class="pagenumber"/> of <span class="pagecount"/>
         </center>
    </div>


    <img src="{!URLFOR($Resource.WaterMark)}" width="100%" height="100%" 
     style="position: fixed;background-repeat:repeat;left: 0cm; top:0cm; z-index:-1"/>

    <apex:variable var="PageNum" value="{!1}"/>
    <apex:outputPanel layout="block" style="height:30px;" rendered="{!PageNum > 1}"/>
    <table>
        <thead>
        <tr>
          <th>ITEM</th>
          <th>DESCRIPTION</th>
          <th>QTY</th>
          <th>STANDARD UNIT PRICE</th>
          <th>EXTENDED PRICE</th>
        </tr>
      </thead>
<tfoot>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
</tfoot>
<tbody>
<apex:repeat value="{!CustQuoteItem}" var="line">
   <tr>
   <th></th>
   <th></th>
   <th></th>
   <th></th>
   <th></th>
   </tr>
       <apex:variable var="PageNum" value="{!PageNum+1}"/>
</apex:repeat>
</tbody>
</table>

<div style="page-break-before: always">&nbsp;</div>


2015年11月5日 星期四

Visualforce PDF 支援之字形 - Fonts Available When Using Visualforce PDF Rendering

Visualforce PDF 支援之字形


Fonts Available When Using Visualforce PDF Rendering



Visualforce PDF rendering supports a limited set of fonts. To ensure that PDF output renders as you expect, use the supported font names.
For each typeface, the first font-family name listed is recommended.
Typefacefont-family Values
Arial Unicode MS
  • Arial Unicode MS
Helvetica
  • sans-serif
  • SansSerif
  • Dialog
Times
  • serif
  • Times
Courier
  • monospace
  • Courier
  • Monospaced
  • DialogInput

於pageMessage中跳行 - Break Line in a apex:pageMessage

處理多筆錯誤訊息時常需要於Message區塊中跳行
以下方式可實現跳行的需求

Controller :

public class LineBreakController
{
    public String str{get;set;}
    public LineBreakController()
    {
       str = 'This is Line 1 \n This is Line 2';           //Your Error Message.
    }
}


VisualForce Page :

<apex:page controller="LineBreakController">
     <apex:pageMessage summary="{!SUBSTITUTE(JSENCODE(str ), '\\n', '<br/>')}" severity="warning" strength="3" escape="false" />

</apex:page>