Is this bug or am i missing something? AccordionPanel & Tab

UI Components for JSF
salman4u
Posts: 78
Joined: 24 Jan 2010, 10:28

14 Mar 2010, 05:53

Hello,

I don't know whether this is my luck or what, but whichever components i try my hands at, they either have serious bugs or something strange happens and components don't work properly. I was just trying to show RSSFeeds on my JSF page by parsing xml, but i knew it beforehand only, something strange will happen and infact it did. Essentially i am creating p:tab objects and adding it to accordionpanel but it shows simple text instead of fancy look of AccordionPanel. This is my code.

Code: Select all

   <p:accordionPanel binding="#{IndexBean.accordionPanel}">
                                                
    </p:accordionPanel>
This is the bean method :-

Code: Select all

public AccordionPanel getAccordionPanel() {
        
        List<RssFeed> objList = getRssFeed();
        if(objList != null){
            for(RssFeed objRssFeed : objList){



                Tab objTab = new Tab();
                objTab.setTitle(objRssFeed.getTitle());
                HtmlOutputText objHtmlOutputText = new HtmlOutputText();
                objHtmlOutputText.setStyle("color:black;");
                objHtmlOutputText.setValue(objRssFeed.getDescription());
                objTab.getChildren().add(objHtmlOutputText);
                accordionPanel.getChildren().add(objTab);
                objTab.setParent(accordionPanel);
                
            }
        }
            
        return accordionPanel;
    }
Constructor :-

Code: Select all

 public IndexBean() {
 accordionPanel = new AccordionPanel();
        accordionPanel.setActiveIndex("0");
        accordionPanel.setAnimate(true);
    }
Is this bug? or am i not doing it properly? The same thing happens with TabSlider. This is the same code for that, and just see the inconsistency. This time even plain text is not shown.

Code: Select all

  <p:tabSlider binding="#{IndexBean.tabSlider}">
                                            
    </p:tabSlider>

Code: Select all

 public TabSlider getTabSlider() {
          List<RssFeed> objList = getRssFeed();
             tabSlider = new TabSlider();
       // tabSlider.setEffect("easeInElastic");
        if(objList != null){
            System.out.println("Inside");
            for(RssFeed objRssFeed : objList){
                Tab objTab = new Tab();
                objTab.setTitle(objRssFeed.getTitle());
//                HtmlOutputText objHtmlOutputText = new HtmlOutputText();
//                objHtmlOutputText.setValue(objRssFeed.getDescription());
//                objTab.getChildren().add(objHtmlOutputText);
//
                tabSlider.getChildren().add(objTab);
            }
        }
        return tabSlider;
    }
Please help cagatay!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

15 Mar 2010, 00:14

This is not a bug of PrimeFaces, you are trying to initialize components but still trying to use component binding. You need to let JSF to pass component references to you and remove code like new TabSlider(), new AccordionPanel().

salman4u
Posts: 78
Joined: 24 Jan 2010, 10:28

15 Mar 2010, 11:28

Great cagatay!! :P
Actually i belong to Asp.net background and i am not well versed with JSF. This is my first hand at Java, JSF and Primefaces.!

I will do it the way you said and let you know more. Thank you

salman4u
Posts: 78
Joined: 24 Jan 2010, 10:28

15 Mar 2010, 13:41

Hi cagatay!
things not working out. I only get nullpointerexception if i don't do new. Please clear my JSF fundas. This is my code. Kindly tell me where am i wrong? I don't see set printed in my glassfish console. Do i need to do anything special on page to set the property? like in jsp we do jsp:usebean? Please help me i am stuck. :(

Code: Select all

@ManagedBean(name = "IndexBean")
@RequestScoped
public class IndexBean {
 private AccordionPanel accPanel = null;

    public void setAccPanel(AccordionPanel accPanel) {
        System.out.println("Set");
        this.accPanel = accPanel;
    }
 public AccordionPanel getAccPanel() {
        
        List<RssFeed> objList = getRssFeed();
        if(objList != null){
            for(RssFeed objRssFeed : objList){
                Tab objTab = new Tab();
                objTab.setTitle(objRssFeed.getTitle());
                HtmlOutputText objHtmlOutputText = new HtmlOutputText();
                objHtmlOutputText.setStyle("color:black;");
                objHtmlOutputText.setValue(objRssFeed.getDescription());
                objTab.getChildren().add(objHtmlOutputText);
                accPanel.getChildren().add(objTab);
                
            }
        }
        return accPanel;
    }
 public IndexBean() {
//empty constructor. No new thing done!
}
}
page :-

Code: Select all

<p:accordionPanel binding="#{IndexBean.accPanel}">
                                                
                                            </p:accordionPanel>

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

15 Mar 2010, 16:21

Don't you ever see; Set in console due to: System.out.println("Set"); ?

salman4u
Posts: 78
Joined: 24 Jan 2010, 10:28

15 Mar 2010, 16:33

No! i don't cagatay! that's why it's throwing NullPointerException. Please help me. I've wasted my whole day for this without doing anything productive. I am learning JSF as well as Primefaces at same time. You can run the given code and tell me whether you are able to run or not. You can remove getRssfeeds function and instead bind a List<String> to see if it works or not but please do something :(

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

15 Mar 2010, 16:40

Unfortunately I don't have the time to run this code, does a standard JSF component binding works;

Can you try HtmlInputText with h:inputText binding?

salman4u
Posts: 78
Joined: 24 Jan 2010, 10:28

15 Mar 2010, 17:44

No! it doesn't work HtmlInputText either. Let me post on some JSF forum and find it out.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

16 Mar 2010, 18:24

What is your environment? JSF version?

salman4u
Posts: 78
Joined: 24 Jan 2010, 10:28

17 Mar 2010, 04:16

Hi cagatay,
I got it working :). It was my mistake only. When i wrote the same code in setter method it worked fine. :D

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests