0

プレーンなcommandLinkを機能させようとしています。このページのコードスニペットは次のとおりです。

<div class="item-single">
    <h:graphicImage value="image/screenshots/#{collectionListBean.collectionListTeaser[0].screenshot}" alt="Screenshot #{collectionListBean.collectionListTeaser[0].title}"/>
    <div class="item-title">
        <h:form id="teaser0">
            <h:commandLink value="#{collectionListBean.collectionListTeaser[0].title}" action="#{collectionBean.showCollection(collectionListBean.collectionListTeaser[0].id)}" />    
        </h:form>
    </div>
    <div class="item-description">
        <p>
            <h:outputText value="#{collectionListBean.collectionListTeaser[0].persons.get(0).person.getFullName()}" />
        </p>
    </div>
</div>

タイトルが正しく表示されるため、バッキングBeanとリストが使用可能でアクセス可能です。CollectionBeanも利用可能でアクセス可能です。リストのサイズは固定されており、javascriptギャラリー内で使用されます。これが、ui:repeatまたはh / p:dataTable要素を使用しなかった理由です。

BalusCの一般的な問題のリストも確認しました

アクションはバッキングBeanで呼び出されていません。ブラウザー・コンソールで次のjavascriptエラーが発生します。

Uncaught TypeError: Cannot read property 'teaser0:_idcl' of undefined

バッキングBean(collectionBean)の関連コードは次のとおりです。

@Named("collectionBean")
@Scope("access")
@ViewController(viewIds = {ViewIds.EDIT_COLLECTION, ViewIds.SHOW_COLLECTION,     ViewIds.EDIT_COLLECTION, ViewIds.METADATA_COLLECTION_ADMIN,     ViewIds.EDIT_COLLECTION_EXISTING, ViewIds.COLLECTION_LIST, ViewIds.HOME})
public class CollectionBean extends CollectionBeanBase {

.
.
.
public String showCollection(long id) {
    //Check if user is admin, if yes, allow to edit metadata
    Authentication auth=SecurityContextHolder.getContext().getAuthentication();
    this.collection = collectionService.findById(id);
    if (!(auth instanceof AnonymousAuthenticationToken)){
        role=auth.getAuthorities().iterator().next().getAuthority();
        if(role.equalsIgnoreCase("ROLE_ADMIN")) {
            this.collection.setEdit_flag(true);
            return ViewIds.EDIT_COLLECTION;
        }          
    }

    return ViewIds.SHOW_COLLECTION;
}

誰かが問題が何であるかについての考えを持っていますか?ヒントは大歓迎です!よろしくお願いします!

4

2 に答える 2

0

これはcommandLinkですが、なぜメソッドに値を渡すのですか。

使える手段

<f:param name="id" value="#{collectionListBean.collectionListTeaser[0].id}"/>

その価値を実際に簡単に得ることができます。

お気に入り

 public String showCollection() {

FacesContext fc = FacesContext.getCurrentInstance();

        Object id = fc.getExternalContext().getRequestParameterMap().get("id");

    System.out.println(id);

    return ViewIds.SHOW_COLLECTION;
    }

これが最善の方法だと思います。

于 2012-07-03T10:28:45.750 に答える
0

jQueryギャラリーの影響を受けるすべてのdivをラップするように要素を再配置したところ、チャームのように機能するようになりました。

于 2012-07-03T12:48:06.150 に答える