2012-07-03 2 views
0

나는 commandLink를 작동 시키려고합니다. 백킹 빈과 목록을 사용할 수 및 액세스 할 수 있도록JSF 2.0 commandLink - 액션이 호출되지 않습니다. javascript erro

<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> 

제목이 올바르게 표시됩니다 : 다음 페이지의 코드이다. CollectionBean도 사용할 수 있으며 액세스 할 수 있습니다. 목록은 고정 크기이며 자바 스크립트 갤러리 내부에서 사용되어 ui : repeat 또는 h/p : dataTable 요소를 사용하지 않은 이유입니다. 여기

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

등판 관련 코드 :

은 또한 브라우저 콘솔에 BalusC 'S List of common problems

액션이 기가 빈에서 호출되지 않는, 나는 다음과 같은 얻을 자바 스크립트 오류를 ​​확인했다 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; 
} 

누구에게 어떤 문제가있을 수 있습니까? 어떤 힌트도 높이 평가됩니다! 미리 감사드립니다!

답변

0

jQuery 갤러리의 영향을받는 div를 모두 감싸기 위해 요소를 재정렬하고 이제는 매력처럼 작동합니다.

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; 
    } 

같은

나는이 그것을 할 수있는 가장 좋은 방법이라고 생각합니다.

+0

미안하지만 왜 f : param 태그를 사용하고 FacesContext를 사용하여 가져올 수 있습니까? JSF 2.0 기능을 사용하고 EL을 사용하여 매개 변수를 전달하는 것이 훨씬 쉽고 (더 깔끔한) imho입니다. 또한 아무 것도 바뀌지 않으므로 내 질문에 대한 대답을 어떻게 볼 수는 없지만 답변을 주셔서 감사합니다. – user871784

+0

확인. 이해 했어. 메소드 인자를 long으로 변경하십시오. – KSHiTiJ

+0

을 클릭하고 빈 공백 인 myMethod (긴 ID) { System.out.println ("id is :"+ id); } – KSHiTiJ

관련 문제