Visualforce 기본 사항 08

Jaehyun_Ban·2022년 4월 8일
0

08. 정적 리소스 사용


📄 끄적끄적

static Resources에 public으로 파일을 업로드하면 콘솔창에서 사용할 수 있다
EX) {! $Resource.jQuery} 로 사용가능



에러(해결!)

모르겟네...........

거의 2시간 걸려버렷다

trailhead에선 경로를 jquery/images/icons-png/eye-black.png로 해놓았는데 최상위 경로에 jquery가 있는것을 아래와 같이 지워주니 해결

<apex:page showHeader="false" sidebar="false" standardStylesheets="false">
    <!-- Add static resources to page's <head> -->
    <apex:stylesheet value="{!
        URLFOR($Resource.jQueryMobile,'jquery.mobile-1.4.5.css')}"/>
    <apex:includeScript value="{! $Resource.jQueryMobile }"/>
    <apex:includeScript value="{!
        URLFOR($Resource.jQueryMobile,'jquery.mobile-1.4.5.js')}"/>
    <div style="margin-left: auto; margin-right: auto; width: 50%">
        <!-- Display images directly referenced in a static resource -->
        <h3>Images</h3>
        <p>A hidden message:
            <apex:image alt="eye" title="eye"
                url="{!URLFOR($Resource.jQueryMobile, 'images/icons-png/eye-black.png')}"/>
            <apex:image alt="heart" title="heart"
                url="{!URLFOR($Resource.jQueryMobile, 'images/icons-png/heart-black.png')}"/>
            <apex:image alt="cloud" title="cloud"
                url="{!URLFOR($Resource.jQueryMobile, 'images/icons-png/cloud-black.png')}"/>
        </p>
    <!-- Display images referenced by CSS styles, all from a static resource. -->
    <h3>Background Images on Buttons</h3>
    <button class="ui-btn ui-shadow ui-corner-all 
        ui-btn-icon-left ui-icon-action">action</button>
    <button class="ui-btn ui-shadow ui-corner-all 
        ui-btn-icon-left ui-icon-star">star</button>
    </div>
</apex:page>


🎯 Challenge

<apex:image>를 이용해 올려둔 static파일의 경로를 잘 지정해주기만 하면 된다.

<apex:page >
    <apex:image alt="cat" title="cat"
                url="{!URLFOR($Resource.vfimagetest, 'cats/kitten1.jpg')}"/>
</apex:page>

0개의 댓글