PrimeFaces'da OrderList bileşeni kullanmaya çalışıyorum. Ekrandaki değerlerin yerlerini değiştirip dialog penceresinde bunu göstermeye çalışıyorum. Öncelikle eğer bir coverter kullanmazsam String sınıfında pojo'daki değişkenlerin olmadığı şeklinde garip bir hata alıyorum. Eğer converter kullanırsam Bu kez de dialog içerisinde ui:repeat ile yazdırmak istediğim kısımlar için NumberFormatException ve Casting hatası veriyor. Hatayı nasıl çözüme kavuşturabiliriz? Kodlar şu şekilde:

OrderListBean

package orderList;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean 
@SessionScoped
public class OrderListBean {
List<Tutors> tutorList;

public List<Tutors> getTutorList() {
    return tutorList;
}

public void setTutorList(List<Tutors> tutorList) {
    this.tutorList = tutorList;
}

@PostConstruct
public void initialize()
{
    tutorList=new ArrayList<>();

    Tutors rahmanHoca=new Tutors("Rahman", "Usta", "kodcu.com");
    Tutors akinHoca=new Tutors("Akın", "Kaldıroğlu", "SelSoft Acamedy");
    Tutors cagatayHoca=new Tutors("Çağatay", "Çivici", "Prime Technology");

    tutorList.add(new Tutors("Rahman", "Usta", "kodcu.com"));
    tutorList.add(new Tutors("Akın", "Kaldıroğlu", "SelSoft Acamedy"));
    tutorList.add(cagatayHoca);

}

}

package orderList;

public class Tutors {      
String name;
String surname;
String company;

public Tutors()
{

}

public Tutors(String name,String surname,String company)
{
    this.name=name;
    this.surname=surname;
    this.company=company;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getSurname() {
    return surname;
}

public void setSurname(String surname) {
    this.surname = surname;
}

public String getCompany() {
    return company;
}

public void setCompany(String company) {
    this.company = company;
}

}

TutorConverter

package orderList;

import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import javax.faces.convert.ConverterException; import javax.faces.convert.FacesConverter;

   @FacesConverter("tutorConverter")
    public class TutorConverter implements Converter {
     List<Tutors> tutorList=new ArrayList<>();
    public Object getAsObject(FacesContext fc, UIComponent uic, String value) {

    System.out.println("Gelen Value:"+value);
    if(value != null && value.trim().length() > 0) 
    {
        try 
        {
            String[] dizi=value.split(",");
            for(int i=0;i<dizi.length;i++)
            {
                System.out.println(dizi[i]);
            }

            int j=0;
            tutorList.add(new Tutors("","",""));
            tutorList.add(new Tutors(dizi[j], dizi[j+1], dizi[j+2]));
            for(Tutors t:tutorList)
            {
                System.err.println(t.name+t.surname+t.company);
            }
            return tutorList;
        } 
        catch(Exception e)   
        {
            System.err.println("Hata Meydana Geldi\\n:"+e);
            throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error", "Not a valid theme."));
        }
    }
    else 
    {
        return null;
    }      
}

public String getAsString(FacesContext fc, UIComponent uic, Object object) {
    if(object != null) 
    {  
        return String.valueOf(((Tutors)object).getName())+","+String.valueOf(((Tutors)object).getSurname())+","+String.valueOf(((Tutors)object).getCompany());            
    }
    else 
    {
        return null;
    }

}

}

orderList.xhtml

               <?xml version='1.0' encoding='UTF-8' ?>
               <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-        transitional.dtd">
                 <html xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:h="http://xmlns.jcp.org/jsf/html"
                  xmlns:p="http://primefaces.org/ui"
                  xmlns:f="http://xmlns.jcp.org/jsf/core"
                   xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
              <h:head>
             <title>OrderList Bileşeni</title>
             </h:head>
             <h:body>
            <h:form>
            <p:orderList controlsLocation="right" converter="tutorConverter" value="#{orderListBean.tutorList}" itemValue="#{tutor}" var="tutor">
            <f:facet name="caption">Java Hocalarımız</f:facet>

            <p:ajax event="select"/>
            <p:ajax event="unselect"/>
            <p:ajax event="reorder"/>

            <p:column>
                <h:outputText value="#{tutor.name} #{tutor.surname} #{tutor.company}"/>
            </p:column>
        </p:orderList>

        <p:commandButton value="Gönder" update="gridPanel"  oncomplete="PF('dialogWindow').show()"/>

        <p:dialog id="dialogWindow" width="400" header="hoca" modal="true" widgetVar="dialogWindow" showEffect="fade" hideEffect="fade">
            <h:panelGrid columns="1" id="gridPanel">
                <ui:repeat value="#{orderListBean.tutorList}" var="tutor">
                    <h:outputText value="#{tutor.name} #{tutor.surname} #{tutor.company}"/>/>
                </ui:repeat>
            </h:panelGrid>
        </p:dialog>
    </h:form>
</h:body>
</html>

alt text

Server Log'u:

    Severe:   Error Rendering View[/orderList.xhtml]
    java.lang.NumberFormatException: For input string: "name"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at javax.el.ListELResolver.toInteger(ListELResolver.java:409)
at javax.el.ListELResolver.getValue(ListELResolver.java:202)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:140)
at com.sun.el.parser.AstValue.getValue(AstValue.java:204)
at com.sun.el.parser.AstDeferredExpression.getValue(AstDeferredExpression.java:63)
at com.sun.el.parser.AstCompositeExpression.getValue(AstCompositeExpression.java:68)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:174)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at com.sun.faces.facelets.component.RepeatRenderer.encodeChildren(RepeatRenderer.java:104)
at com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:621)
at com.sun.faces.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:1110)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:582)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1689)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIForm.visitTree(UIForm.java:371)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:403)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:322)
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:430)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)

    Severe:   java.lang.NumberFormatException: For input string: "name"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at javax.el.ListELResolver.toInteger(ListELResolver.java:409)
at javax.el.ListELResolver.getValue(ListELResolver.java:202)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:140)
at com.sun.el.parser.AstValue.getValue(AstValue.java:204)
at com.sun.el.parser.AstDeferredExpression.getValue(AstDeferredExpression.java:63)
at com.sun.el.parser.AstCompositeExpression.getValue(AstCompositeExpression.java:68)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:174)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at com.sun.faces.facelets.component.RepeatRenderer.encodeChildren(RepeatRenderer.java:104)
at com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:621)
at com.sun.faces.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:1110)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:582)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1689)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIForm.visitTree(UIForm.java:371)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:403)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:322)
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:430)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)

soruldu: 26 Eki '15, 04:04

ilkay's gravatar image

ilkay
726333649
cevap kabul oranı: 13%

converterda neden List<tutor> tutorList =new ArrayList<tutor>(); olarak tanım var ne de olsa converter her bir kayıt için döneceği için null dönecek.

(26 Eki '15, 06:25) kurtomerfaruk kurtomerfaruk's gravatar image

Merhaba, List yerine Tutors tanımlaman işini görecektir.

@Override
    public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
        Tutors tutor = new Tutors();
        System.out.println("Gelen Value:" + value);
        if (value != null && value.trim().length() > 0) {
            try {
                String[] dizi = value.split(",");
                for (int i = 0; i < dizi.length; i++) {
                    System.out.println(dizi[i]);
                }
                tutor.setName(dizi[0]);
                tutor.setSurname(dizi[1]);
                tutor.setCompany(dizi[2]);
                return tutor;
            } catch (Exception e) {
                System.err.println("Hata Meydana Geldi\\n:" + e);
                throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error", "Not a valid theme."));
            }
        } else {
            return null;
        }
    }
permanent link

cevaplandı: 26 Eki '15, 06:29

kurtomerfaruk's gravatar image

kurtomerfaruk
1.3k222940
cevap kabul oranı: 29%

Teşekkür ederim bu hali ile çalışıyor şu anda kod.

(26 Eki '15, 06:45) ilkay ilkay's gravatar image

Dialog içerisinde datatable kullanmayı düşünmez misin? Hem daha düzenli olur hemde converter ihtiyacın olmaz.

permanent link

cevaplandı: 26 Eki '15, 05:53

SaRPaRDa's gravatar image

SaRPaRDa
5.0k213165
cevap kabul oranı: 27%

DataTable kullanmayı düşündüm fakat eğer ui:repeat kullanamamak benim eksikliğim olur ve öğrenmem gerekir diyerek bunun üzerine gittim. Teşekkür ederim.

(26 Eki '15, 06:46) ilkay ilkay's gravatar image
Cevabınız
toggle preview

Bu soruyu takip et

E-Posta üzerinden:

Üyelik girişi yaptıktan sonra abonelik işlemlerini yapabilirsiniz

RSS üzerinden:

Cevaplar

Cevaplar ve Yorumlar

Yazı Formatlama

  • *italic* ya da _italic_
  • **bold** ya da __bold__
  • link:[text](http://url.com/ "başlık")
  • resim?![alt text](/path/img.jpg "başlık")
  • liste: 1. Foo 2. Bar
  • temel HTML etiketleri de kullanılabilir

Bu sorunun etiketleri:

×97
×3
×1
×1

Soruldu: 26 Eki '15, 04:04

Görüntüleme: 486 kez

Son güncelleme: 26 Eki '15, 07:32

powered by BitNami OSQA