开发者

Managedbean could not be created Error While passing parameters on URL

开发者 https://www.devze.com 2023-01-18 05:37 出处:网络
I\'m trying to pass parameters on URL but I get Managed bean \"Cant instantiate class:\" error. Code is Here:

I'm trying to pass parameters on URL but I get Managed bean "Cant instantiate class:" error. Code is Here:

create url:

  <h:outputLink id="link"
     value="#{facesContext.externalContext.requestContextPath}/Public/Home/altKanallar.jsf?id=#{item.id}&name=#{item.name}">
     <h:outputText value="#{item.name}" />
  </h:outputLink>

altKanallar.jsf

    <h:form>
        <div style="text-align: center;">

        <div style="text-align: left;">
        <h:panelGrid style="font-size: 12px; text-decoration:none; " width="100%">
            <h:dataTable value="#{altKanallarBean.categories}" var="item"  style=" width : 100%;">
                <h:column>
                    <h:outputLink id="link"
                        value="#{facesContext.externalContext.requestContextPath}/Public/Home/default.jsf">
                        <h:outputText value="#{item.name}" />
                    </h:outputLink>

                    <div style="style=clear:both; font-size:1px; height:2px; line-height:1px;">
                    </div>
                    <div style="border-bottom:1px solid #D3E8FF; font-size:1px; height:1px; line-height:1px;">
                    </div>
                    <div style="style=clear:both; font-size:1px; height:2px; line-height:1px;">
                    </div>
                </h:column>

            </h:dataTable开发者_JS百科>
        </h:panelGrid>
        </div>
    </h:form>

AltKanallarBean.java

public class AltKanallarBean {


    private   List<com.uzmantv.data.category.Item> categories;  

    public AltKanallarBean(){
        HttpServletRequest request=(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
        System.out.println(request.getParameter("name"));
        System.out.println(request.getParameter("id"));
        categories = RestServices.getCategoriesById(Long.parseLong(request.getParameter("id"))).getItems();
        name = request.getParameter("name");
    }



    public List<com.uzmantv.data.category.Item> getCategories() {
        return categories;
    }



    public void setCategories(List<com.uzmantv.data.category.Item> categories) {
        this.categories = categories;
    }
}


Make sure that constructor AltKanallarBean() does not throw an exception. In general this is not recommended to invoke business logic in constructors.


Thanks for your support. Problem has solved.

Jboss didn't deployed the AltKanallarBean class. it took hours to decide close and reopen Eclipse and clean jboss.

0

精彩评论

暂无评论...
验证码 换一张
取 消