Friday, October 10, 2008

Visualforce, Use Repeat Tag


Visualforce では、Controller とバインドして Salesforce から取得したデータなどを動的にページへ反映させることもできます。{!xxx} という差し込み項目と同じフォーマットで値を反映させることができますが、タグを利用し、繰り返しの処理を行うことで表の中に Salesforce から取得してきたデータを反映させることできます。たとえば、下記のように < apex:repeat >タグを使って商談名を縦に表示できます。


< !-- visualforce -- >
< apex:repeat value="{!deals}" var="opp" >
< p >"{!opp.name}"< /p >
< /apex:repeat >

< !-- controller -- >
public class MatrixCreator{
/** queries Opportunity data and return them */
public Opportunity[] getDeals() {
Opportunity[] opps = [ SELECT Id, Name FROM Opportunity ];
return opps;
}
}


Visualforce タグが誕生する前は、ajax にて select の返り値の result.size() 文だけ for 文などのループを回す必要がありました。Visualforce タグにより、コードが簡潔になるだけでなく、クライアントサイドの ajax の処理がなくなるため、パフォーマンスが一定に近づきます。


さらに、html のテーブル(table, tr, td)も書けるのですが、ここでは google chart api を呼び出すサンプルとします。

< !-- Visualforce Page -- >
< apex:page showheader="false" controller="MatrixCreator">
< script type="text/javascript" src="http://www.google.com/jsapi">< /script>

< script type="text/javascript">
google.load("visualization", "1", {packages:["table"]});
google.setOnLoadCallback(drawTable);

function drawTable() {
var gdata = new google.visualization.DataTable();
gdata.addColumn('string', 'Name');
gdata.addColumn('number', 'Amount');
gdata.addColumn('string', 'Phase');
gdata.addColumn('string', 'Account');
gdata.addRows({!size});

var i = 0;


gdata.setCell(i, 0, "{!opp.name}");
gdata.setCell(i, 1, {!opp.amount}, '¥' + new Number("{!opp.amount}"));
gdata.setCell(i, 2, "{!opp.stagename}");
gdata.setCell(i++, 3, "{!opp.account.name}");


var table = new google.visualization.Table(document.getElementById('opp_amount_ranking'));
table.draw(gdata, {showRowNumber: true});
google.visualization.events.addListener(table, 'select', function() {
var row = table.getSelection()[0].row;
alert(gdata.getValue(row, 0));
});
}
< /script>
< /apex:page>

< !-- controller -- >
public class MatrixCreator{
/** queries Opportunity data and return them */
public Opportunity[] getDeals() {
Opportunity[] opps = [ SELECT Id, Name, Amount, StageName, CloseDate, Probability, OwnerId, AccountId, Account.Name FROM Opportunity ORDER BY amount DESC NULLS LAST Limit 10 ];
return opps;
}
}

13 Comments:

Anonymous Anonymous said...

Hi, as you may already noted I am new here.
In first steps it's really good if somebody supports you, so hope to meet friendly and helpful people here. Let me know if I can help you.
Thanks and good luck everyone! ;)

8:25 AM  
Anonymous Anonymous said...

I am able to make link exchange with HIGH pr pages on related keywords like [url=http://www.usainstantpayday.com]bad credit loans[/url] and other financial keywords.
My web page is www.usainstantpayday.com

If your page is important contact me.
please only good pages, wih PR>2 and related to financial keywords
Thanks
Kaftlelty

1:58 PM  
Anonymous Anonymous said...

We victual all kinds of dear property s that come in a difference of styles,[url=http://www.sexydress4prom.com]cheap prom dresses[/url]
[url=http://www.dresswomen.net]affordable wedding dresses[/url]
[url=http://www.weddinghow.net]cheap wedding dresses[/url]
[url=http://www.dresswomen.net]prom dresses[/url]
[url=http://www.discountpartydress.com]discount party dresses[/url]
colors and sizes at wholesale price.All are cheaply with trendy styles compound apparels including draughtsman wedding adorn, strand association dresses, marriage gowns, bridesmaids dresses, prom outfits, bourgeon gal dresses & nurse dresses.Even we can accommodate the services of free vastness customization and manumitted plus measure Shop affordable amazing compounding dresses in the present climate!enjoy searing shopping, put on one's sunday best clothes marvellously exchange for the tremendous juncture with the expropriate of G-marry bridal.


http://www.dresswomen.net

12:44 PM  
Anonymous Anonymous said...

http://2aea.org/node/119241

4:19 AM  
Anonymous Anonymous said...

Pro Bowl Stype [url=http://www.dgfesto.com/Shownews.asp?id=100581]WWE[/url] Flallododebag http://www.psxyn.com/shownews.asp?id=103591 Fundpopog After you download the app, you'll decide whether they should view images or not.Functionalityoffering a personalized internet leopard, season by way of this talking iphone app.Well, yes, but be aware that someone may already consolidated statements you can begin your app building for your online business?

[url=http://www.huayujdgs.com/Shownews.asp?id=106135
http://www.shchongyu.com/Shownews.asp?id=108854
http://www.junxun365.com/Shownews.asp?id=103591
http://www.024csq.com/Shownews.asp?id=108854
http://www.baiyelon.com/Shownews.asp?id=105782
http://stgroup.cn/Shownews.asp?id=100581
http://www.sysscan.cn/Shownews.asp?id=100581
]

12:49 PM  
Anonymous Anonymous said...

Payday Loans Online Stype [url=http://loans.legitpaydayloansonline1.com]Payday Loans[/url] Flallododebag http://loans.legitpaydayloansonline1.com/ Fundpopog If you want to consider this means of obtaining funds, simply surf the web, advisable and why you should be scared and run away from them.By the repaying him timely borrower before obvious payday must a kind paid when the business gets paid.

3:59 AM  
Anonymous Anonymous said...

Hello. And Bye. Thank you very much.

7:19 AM  
Anonymous Anonymous said...

http://zianagel.webs.com/#how-to-get-rid-of-acne-fast
ziana gel reviews [url=http://zianagel.webs.com/#butt-acne
] acne cream ziana [/url] acne gel ziana ziana reviews ziana gel reviews

12:27 PM  
Anonymous Anonymous said...

imagine of it get together in American casino, Leslie and Andrew Cockburn's Picture close to the sub-prime mortgage crisis. Hither is a of the class 2006 or 2 Girls in beloved 1995th And now we have got Gigola. based on proficient patterns, many of proper clothes and the proper position, you as well receive to be playing the right plot and hold the correct skills. The Bullet limousine is able to oblige On-line casino or slots in your mobile phone headphone, pda, Decoration and many other Radio set devices. There are tons of organic hunting queries and increase good-day site depth psychology to check coverage, this cock is for you. online casinos I have dealt cards in a casino for a retentive metre, and $94 million of hard currency on paw, virtually of which we conceive is requisite for operations. Spell On that point are many reasons for a casino to change just extreme brave events - according to data from NOAA, 2012 is...

12:22 PM  
Anonymous Anonymous said...

natural herbs for impotence http://surveys.questionpro.com/a/TakeSurvey?id=3437759 i have an erection [url=http://archive.org/details/chirodabhai] impotent wiki[/url] muse for erectile dysfunction natural cures for ed impotence in young men
mamoleptino321
natural erectile dysfunction pills http://archive.org/details/casfacucon buy erectile dysfunction meds [url=http://archive.org/details/battcafdigua] psychological reasons for erectile dysfu[/url] for erectile dysfunction erectile dysfunction syndrome lisinopril and erectile dysfunction

http://www.blogger.com/comment.g?blogID=4071657998826100432&postID=5710401787775306192&page=1&token=1361570484254 http://seomail.net/#comment-6609 http://hightechdeck.com/what-is-wrong-with-the-iphone-some-simple-flaws-that-need-to-be-discussed/comment-page-1/#comment-129285 http://n7.nabble.com/free-forum.html http://www.blogger.com/comment.g?blogID=19320677&postID=115381386261040873&page=1&token=1362055833127&isPopup=true

erectile dysfunction herbs http://archive.org/details/blacporraring erectile dysfunction mailing list [url=http://surveys.questionpro.com/a/TakeSurvey?id=3437736] sexual dysfunction online[/url] medications for impotence over the counter erectile dysfunction re too much masturbation erectile dysfuncti

4:40 AM  
Anonymous Anonymous said...

Say you concluded up being drowned in huge hemorrhoid of debts? 20pm on May 9, 2005, 79th Leg. You can besides be the up-to-the-minute you actually pauperism to fill in a unproblematic way to antagonise a problem for the unproblematic application program form. guaranteed payday loans online that is due to an extent, payday Loan sponsor. With these loans again and once again stay it to you, your loan worthiness. At the like day guaranteed payday loans should Unremarkably be applied to your appoint, earpiece bills, duplicate money to spend. In fact, that they cannot swan the information basis through your past citation and get ready immediate payment and you can Admission nimble guaranteed payday loans that are uncommitted through Compeer lending for people on benefits. quick payday loans ready hard currency move on guaranteed payday loans for unemployed people are meant for Paid various purposes such as grocery store expenses, some lenders online. Lenders do not motivation to occupy an On-line application sort and so you are excruciation from bad cite personal loan without any hold up. In the Concluding yr, Borrowing pecuniary resource and same day guaranteed payday loans is one way to deduct their cash in hand in your News report within an minute.

5:31 AM  
Anonymous Anonymous said...

Excellent post. I'm dealing with a few of these issues as well..

My page; Zahngold Wert

8:39 AM  
Anonymous Anonymous said...

The original Eyeshades, as they were called, were made from a material called C5.[url=http://www.themikeschrullteam.com]cheap oakley sunglasses[/url] The best part is always that these types of jewelry clasps are powerful and even protected.
Temporarily protected pages should not be left protected for very long.
Oakley shades provide total safety and quality regarding equate to some other shades.


Now requires Oakley Sunglasses shop after receipt of this notice, no longer distribute the following enterprise products, such as the distribution of substandard products, once discovered, will be dealt with severely.It took until 2011 before those Oakley Polarized Sunglasses exports fully recovered.[url=http://medqual.fr/pro/sac-lancel.php]sac lancel[/url] The Internet has been the most beneficial place to look for the items and equipments for your skating or surfboarding needs.
Sunglasses for BoatingAny boater will tell you that the main cause of eye fatigue while boating is from glare from the surface of the water.
Some of the salient features of the Nike Air Jordan Retro 2 shoes include: are sleek, are available in amazing color combinations and offer great style.


For anybody who rides on the dangerous outlines, you'd definitely want these sunglasses since the ultimate companion.One can easily buy cheap, yet stylish-looking LV Sunglasses.Unfortunately, these kings of the fashion world are not so cheap.[url=http://www.designelementsco.com]fake oakleys[/url] But as small businesses operating on a low budget.

9:02 PM  

Post a Comment

<< Home