• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calendar display

 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I am building an application that is a montly calendar view of project titles from a database. It's going into a portal, so javascript needs to be nonexistent.
Anyway, I'm using JSF with backing beans, and I'm creating 32 objects (for 31 days and one null day) that will contain: an integer date and project titles that correspond to that date.
My problem comes in when I try to dynamically build the calendar view as a table, with each day equalling one cell. I tried <h:dataTable>, but that wont display horizontally, so I can build the days on the fly. And I also tried creating an html table with a defined width, using a <t:dataList> for each cell, but the rows won't automatically wrap to create the 'calendar view' that the user will expect to see. I also tried <h:panelGrid>, but I can't figure out a way to populate each cell (i.e. day) dynamically inside the panelGrid.

Any ideas?


Thanks,
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use tomahawk's <t:columns> inside datatable to build the columns horizontally.

Will it help?
 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, I dont think so. What I need to do is just populate the 31 cells dynamically and create the calendar view on the fly. I dont want to have to have a different object for each column, that seems like alot more work for nothing.
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the code you are currently trying. I will let you know if it is possible to display the columns dynamically using <t:columns> or not
 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code is 30 objects, which contain the integer of the date. I need to display out the 30 objects (stored in an arraylist) as 30 cells in a table, so <t:columns> will not work because i would then need to divide up the objects into multiple arraylists to display each column. i tried using one column, but again, you end up with a vertical listing instead of a horizontal one that wraps and continues into the next row and the next row until you have populated a calendar view with one arraylist of objects.
 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I got your point. You can use <h:panelGrid> for this as it displays the columns horizontally. In JSP write code something like this:



Now in your Calender class use code like this one


Amend the code according to your needs. I hope this will help?
[ October 31, 2006: Message edited by: Ali Gohar ]
 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, thanks for replying, I'm going nuts with this problem. Unfortunately, I tried a panelGrid with columns=7, but on the 8th, it squeezes it into the same row, instead of wrapping it to the next row so I can populate the whole calendar with one arraylist.

Any other ideas?



(Thanks for all your help on this.)
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the code above, you are using <t:dataList> inside <h:panelGrid>, i guess this is creating problem. Try something like this or tweak it if required:



My guess is that <t:dataList> is creating problem so use the code in my previous post, and check if it works. BTW i haven't tried that
[ November 01, 2006: Message edited by: Ali Gohar ]
 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was a good idea, but nope, still displaying out horizontally instead of vertically. Who knew this would be such a dilemma?
 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I'm playing with the idea of building the htmlPanelGrid in the managed bean called Calendar.class, and seeing if that would work (as you posted earlier..thanks). I have the following in the jsf page, but I keep getting errors. Am I calling the calendarPanel correctly?

<h:panelGrid id="caasdf" binding="#{Calendar.calendarPanel}" columns="7" border="1" cellspacing="0"/>

Do I need to wrap it in an <h:form> tag or something?

Sorry for all the questions, but as you can tell, there's not much support around here for jsf.
 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I'm actually wondering if I'm missing something very basic. My error is telling me:

Managedbean Calendar could not be created Can't instantiate class: 'org.usgs.nbii.Conferences.Calendar'.. class org.usgs.nbii.Conferences.Calendar : java.lang.NullPointerException


So I'm wondering if I need to do something to the project's configuration to be able to build the panelGrid in the bean, instead of using the tag libray in the jsf page?
 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Ali,
I got it! I was getting an error in the backing bean because I wasnt instantiating calendarPanel after I created it.
Thanks SO much for all your help, hopefully I can help you sometime.

:thumb:
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, is it working now? I mean is your problem resolved?
[ November 01, 2006: Message edited by: Ali Gohar ]
 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is! By creating the output using HtmlPanelGrid in the backing bean, then displaying out in a <h:panelGrid> tag, I can get the monthly calendar display i wanted. Again, thanks so much for the help. Now I can actually start on the logic to dynamically populate the dates, depending on what month you choose to view.


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!