• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsf with dojo calendar

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi , I am using dojo calendar [i.e dijit.form.DateTextBox ]in jsf
I am using <rich:tab>, on clicking of the tab i am loading a new page which has the below calendar field.

using it in the following way

<div jsf2dojo='true' name="divname" id="createdDateFromDiv">
<h:inputText id="createdDateFrom" lang="#{refundSearchBean.isArabic?'ar-eg':'en-us'}" value="#{declarationSearchBean.criteria.createdDateFrom}" >
<f:convertDateTime type="date" pattern="yyyy-MM-dd" />
</h:inputText>
</div>

Using the <h:inputText> for loading the calendar

On click of the tab [for the page now to refresh the tabs are in an output panel and i am Rerender the tabs and call the app page.] i am calling a javascript function

<script type="text/javascript" src="../../scripts/dojo.xd.js" djConfig="parseOnLoad: true, extraLocale: ['ar-eg']"></script>
<script type="text/javascript">
dojo.require("dijit.form.DateTextBox");
dojo.require("dojo.parser");
var TYPE_MAP = {
text : 'dijit.form.DateTextBox',
textarea : 'dijit.form.Textarea'
};
dojo.addOnLoad(init);
function init(){
var jsfContainerList = dojo.query("[jsf2dojo='true']");
for(var i=0; i < jsfContainerList.length;i++){
var jsfWidget =_getJsfWidget(jsfContainerList[i]);
if(!jsfWidget) continue;
if('input' == jsfWidget.tagName.toLowerCase() && 'text' == jsfWidget.type.toLowerCase()){
jsfWidget.setAttribute('dojoType',
TYPE_MAP[jsfWidget.type.toLowerCase()]);
jsfWidget.setAttribute('constraints',"{datePattern:'dd/MM/yyyy', min:'2000-01-01',max:'2020-12-31'}")
}
dojo.parser.parse(jsfContainerList[i]);//parse wrapper node
}
}

function _getJsfWidget(node){
var childNodes = node.childNodes;
for(var i = 0; i < childNodes.length; i++){
if(1 == childNodes[i].nodeType){
return childNodes[i];
}
}
return null;
}
</script>


Since the dojo calendar is placed in the <a4j:outputPanel> and it is ReRendered the calendar does not load.

Any solutions ?
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Prathima!

I have been very disappointed in dijit. I've had reliability problems with it, issues with how it basically breaks controls into multiple internal parts that don't map well to the visible declaration, and it's more complex than I like. Also, I've gotten the impression that support for it is less than I'd expected.

In JSF, you're better off using one of the JSF calendar custom controls such as the Tomahawk or RichFaces calendars. Although they can be a little complicated to set up initially, they work simply and reliably and don't require that you write any javascript code to make them work.
 
reply
    Bookmark Topic Watch Topic
  • New Topic