This content has been marked as final.
Show 6 replies
-
1. Re: how to set value in input text on page load
bshashidhar Mar 31, 2009 1:12 PM (in response to senthils)Click HELP for text formatting instructions. Then edit this text and check the preview.
send today-statistics.xhtml page and todaystatistics.getDate method -
2. Re: how to set value in input text on page load
bshashidhar Mar 31, 2009 1:12 PM (in response to senthils)send today-statistics.xhtml page and todaystatistics.getDate method
-
3. Re: how to set value in input text on page load
senthils Mar 31, 2009 1:38 PM (in response to senthils)Hi,
Thanks for your quick reply..
today-statistics.xhtml
----------------------
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ice="http://www.icesoft.com/icefaces/component"
template="||||""template.xhtml">
<s:remote include="todaystatistics"/>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ice="http://www.icesoft.com/icefaces/component"
template="template.xhtml">
<ui:define name="sidebar">
<h:form id="formStatistics">
<s:decorate id="fromDateDecorate_today" template="edit.xhtml">
<ui:define name="label">Form:</ui:define>
<span class="calendar">
<ice:selectInputDate id="fromDate_today" value="#{statistics.fromDateTo}" required="true"
renderAsPopup="true" partialSubmit="true" onkeydown="javascript:return false;">
<f:convertDateTime pattern="yyyy-MM-dd"/>
</ice:selectInputDate>
</span>
</s:decorate>
<s:decorate id="toDateDecorate_today" template="edit.xhtml">
<ui:define name="label">To:</ui:define>
<span class="calendar">
<ice:selectInputDate id="toDate_today" value="#{statistics.toDateTo}" required="true"
renderAsPopup="true" partialSubmit="true" onkeydown="javascript:return false;">
<f:convertDateTime pattern="yyyy-MM-dd"/>
</ice:selectInputDate>
</span>
</s:decorate>
</h:form>
</ui:define>
</ui:composition>
todaystatistics.getDate
-----------------------
@In(required=false) @Out(required=false)
public StatisticsForm statistics = new StatisticsForm();
public String getDate(int reportType) {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat df3 = new SimpleDateFormat("dd-MM-yyyy");
SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM-dd");
StringBuffer msgSmppStr = new StringBuffer();
try {
List result = db1.createQuery("select back from BackupTime back").getResultList();
for (int i=0;i<result.size();i++) {
BackupConsTime report = (BackupConsTime)result.get(i);
BackupConsTimeId reportId = report.getId();
Date tempDate = reportId.getTimeStamp();
statistics.setBackupTime(df1.format(tempDate));
statistics.setFromDateTo(tempDate);
}
} catch(Exception e) {
e.printStackTrace();
}
return msgSmppStr.toString();
} -
4. Re: how to set value in input text on page load
ambrish_kumar Apr 1, 2009 12:41 PM (in response to senthils)Hi,
Here is a simple example for setting values on page load.
My SEAM component is onPageload.
import java.util.Date; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.jboss.seam.annotations.security.Restrict; @Name("onPageload") @Scope(ScopeType.CONVERSATION) @Restrict("#{identity.loggedIn}") public class OnpageloadAction { Date today; public Date getToday() { return today; } public void setToday(Date today) { this.today = today; } public void initialize(){ today = new java.util.Date(); } }
Here is your XHTML page.
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml"> <ui:define name="body"> <h:messages styleClass="message" /> <h:form id="login"> <rich:calendar value="#{onPageload.today}" showInput="true" datePattern="MM/dd/yyyy"/> </h:form> </ui:define> </ui:composition>
and finally your page.xml file.
<?xml version="1.0" encoding="UTF-8"?> <page xmlns="http://jboss.com/products/seam/pages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd"> <action execute="#{onPageload.initialize}"/> </page>
Ambrish
-
5. Re: how to set value in input text on page load
senthils Apr 2, 2009 2:52 PM (in response to senthils)Hi Ambrish,
Thanks a lot for your reply, I placed <action execute=""> tag in my page.xml. its working fine but problem is if i do any other action on the page its getting executed. Finally i solved this using seam remote component.
Regrads,
Senthil -
6. Re: how to set value in input text on page load
msahin35 Oct 26, 2010 6:25 PM (in response to senthils)<action execute="#{onPageload.initialize}" on-postback="false"/>
if you write on postback false this works only one times when loading page. It does not work any other actions. if you want to use this for list initilition you will like this.