AddThis Toolbox を実装したい
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style">
<attribute ca:name="addthis:url">http://www.foobar.org </attribute>
<attribute ca:name="addthis:title">An excellent website</attribute>
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a>
<a class="addthis_button_email"></a>
</div>
このようなものに、これが私のコードです。ホームページのタイトルのみをTwitterボックスに取得します。一般的には機能しますが、属性は統合されていません!
Div oDivAddThis = new Div();
oDivAddThis.setClass("addthis_toolbox addthis_default_style addthis_style");
oDivAddThis.setAttribute("ca:name='addthis:url'", "https://www.test.org");
oDivAddThis.setAttribute("ca:name='addthis:title'",oSearchDAO.getTitle()+" \n "+oSearchDAO.getDescription1()+" \n "+oSearchDAO.getDescription2());
oDivAddThis.setAttribute("addthis:url", "https://test.org.com/?cp="+oSearchDAO.getImage().trim());
oDivAddThis.setAttribute("addthis:title",oSearchDAO.getTitle()+" \n "+oSearchDAO.getDescription1()+" \n "+oSearchDAO.getDescription2());
A compGooglePlus = new A();
compGooglePlus.setClass("addthis_button_google_plusone_share");
compGooglePlus.setAttribute("addthis:url", "https://test.org.com/?cp="+oSearchDAO.getImage().trim());
compGooglePlus.setAttribute("addthis:title",oSearchDAO.getTitle()+" \n "+oSearchDAO.getDescription1()+" \n "+oSearchDAO.getDescription2());
A compFacebook = new A();
compFacebook.setClass("addthis_button_facebook");
A compTwitter = new A();
compTwitter.setClass("addthis_button_twitter");
compTwitter.setAttribute("addthis:url", "https://test.org.com/?cp="+oSearchDAO.getImage().trim());
compTwitter.setAttribute("addthis:title",oSearchDAO.getTitle()+" \n "+oSearchDAO.getDescription1()+" \n "+oSearchDAO.getDescription2());
A compCompact = new A();
compCompact.setClass("addthis_button_compact");
compGooglePlus.setParent(oDivAddThis);
compFacebook.setParent(oDivAddThis);
compTwitter.setParent(oDivAddThis);
compCompact.setParent(oDivAddThis);
私もこのようなことを試しました(クライアント/属性名前空間)
oDivAddThis.setAttribute("ca:name='addthis:url'", "https://test.org/?cp="+oSearchDAO.getImage().trim());
oDivAddThis.setAttribute("ca:name='addthis:title'",oSearchDAO.getTitle()+" \n "+oSearchDAO.getDescription1()+" \n "+oSearchDAO.getDescription2());
どんな助けでも大歓迎です、ありがとう
更新 [解決済み]
Tony ( http://zkfiddle.orgの作者) の助けを借りて、私はそれを動かしました。私の間違いは、サーバー側で明確に評価される setAttibute を使用したことです。
私がしなければならなかったのは、クライアント側で評価される setWidgetAttibute を使用することだけでした。:-) すばらしい。アイデアを投稿してくれた victor に感謝します。また、私を大いに助けてくれた Tony に特に感謝します。