Tassel Data List

2006-08-30 Thread Waimun Yeow

Hi,

Does anyone know how the Data List (Tassel component) works? I  
downloaded the component but found no documentation/demo/example. The  
link to the website does not appear to be legitimately tapestry.  Can  
someone suggest what is a good approach of doing pagination in Tap 3?


Thanks,
waimun.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DynamicSelectionList and ArrayIndexOutOfBoundsException

2006-08-18 Thread Waimun Yeow
The second version of the demo helped me to correct the way custom  
objects are passed in the selection property model classes. I have  
made the changes in my selection model classes and also the  
pageBeginningRender() method.  However, I am still having the same  
problem. I have posted the .page and codes below.


-waimun

!-- .page --
property-specification name=toDepartment  
type=project6.model.UserDepartment

persistent=no /

property-specification name=user type=project6.model.UserAccount
persistent=no /

property-specification name=departmentSelectionModel
		type=org.apache.tapestry.form.IPropertySelectionModel  
persistent=no /


property-specification name=usersByDepartmentList
type=java.util.List initial-value=new java.util.ArrayList()
persistent=no /



property-specification name=userDepartmentDao
type=project6.dao.UserDepartmentDao
global.getApplicationContext().getBean(userDepartmentDao)
/property-specification

property-specification name=userAccountDao
type=project6.dao.UserAccountDao
global.getApplicationContext().getBean(userAccountDao)
/property-specification
component id=referralForm type=Form
binding name=listener expression=listeners.formSubmit/
/component
component id=deptSelection type=PropertySelection
binding name=value expression=toDepartment /
binding name=model expression=departmentSelectionModel /
binding name=disabled expression=false /
static-binding name=submitOnChange value=false /
/component

component id=userSelection type=man:DynamicSelectionList
binding name=parent expression=components.deptSelection /
binding name=value expression=user /
binding name=childList expression=usersByDepartmentList /
/component

!-- .page --

/* method's code for page */

public void pageBeginRender(PageEvent event) {

List allDepartments = getUserDepartmentDao().findAll();

if (getDepartmentSelectionModel() == null) {
setDepartmentSelectionModel(new 
DepartmentSelectionModel(
allDepartments));
}

if (getUsersByDepartmentList().size() == 0) {

DepartmentSelectionModel deptModel = (DepartmentSelectionModel)  
getDepartmentSelectionModel();



for (Iterator it = deptModel.getDepartmentList().iterator(); it
.hasNext();) {


UserDepartment d = (UserDepartment) it.next();

List usersByDepartment = 
getUserAccountDao().findByDepartment(d);

if (usersByDepartment.size() == 0) {
List a = new ArrayList();
a.add(getUserAccountDao().findByUsername(Waimun 
Yeow));
usersByDepartment = a;
}

getUsersByDepartmentList().add(
new 
UsersByDepartmentSelectionModel(usersByDepartment));

}

}


if (getToDepartment() == null) {
setToDepartment((UserDepartment) getDepartmentSelectionModel 
().getOption(4));

}

}
/* method's code for page */

/* models' class */
public class UsersByDepartmentSelectionModel implements  
IPropertySelectionModel, Serializable {


private List usersList = new ArrayList();

private static UserAccountDao dao;

public UsersByDepartmentSelectionModel() {

XmlBeanFactory factory = new XmlBeanFactory(new 
ClassPathResource(
DaoContext.xml));

dao = (UserAccountDao) factory.getBean(userAccountDao);
}

public UsersByDepartmentSelectionModel(List users) {

this();

if (users == null)
return;

usersList = users;
}

public int getOptionCount() {
return usersList.size();
}

public Object getOption(int index) {
return usersList.get(index);
}

public String getLabel(int index) {
return ((UserAccount) usersList.get(index)).getUserName();
}

public String getValue(int index) {
return ((UserAccount) 
usersList.get(index)).getUserId().toString();
}

public Object translateValue(String index) {
return dao.findByUserId

Re: DynamicSelectionList and ArrayIndexOutOfBoundsException

2006-08-18 Thread Waimun Yeow
Yes, indeed the two selection models are suspicious. I used  
PropertySelection to test DepartmentSelectionModel and the value  
displayed by @Insert shows the correct value of the selected entry  
but the list did not generate selected=selected for the entry after  
submit and hence fell back to no entries listed as  
selected=selected. Is that the correct behavior of  
PropertySelection? I am definitely missing something there. By the  
way, I am using binding name=submitOnChange expression=true /  
to test the PropertySelection.


-waimun

On 8/18/06, Shing Hing Man wrote:
   UsersByDepartmentSelectionModel.java  (and
 DepartmentSelectionModel.jav)
 looks suspcious.


 The  UsersByDepartmentSelectionModel.getOption method
 returns a value
 from userLists, but
 UsersByDepartmentSelectionModel.translateValue returns
 a value using a dao.


 You might like to test
 UsersByDepartmentSelectionModel in a standalone
 PropertySelection
 component : select an entry from the drop list. Print
 the selected value in a form
 listener method.

 Shing



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DynamicSelectionList and ArrayIndexOutOfBoundsException

2006-08-15 Thread Waimun Yeow
I am using the DynamicSelectionList (Tap 3) component managed at the  
Tassel site http://equalitylearning.org/Tassel/app?service=direct/1/ 
Search/viewComponentsp=SmatmshDynamicSelectionList


I followed the BikeMaker demo with source code at http:// 
lombok.demon.co.uk/tapestryDemo/welcome


The BikeMaker example above uses StringPropertySelectionModel and  
String[] objects for the drop-down selection lists. However, I  
modified my program to use custom PropertySelectionModel(s) and  
custom objects as value objects in the models.


On the first render of the page, the DynamicSelectionList component  
works exactly what I want to achieve. The options and their labels  
are displayed correctly in the selection lists, and selecting an  
option in the parent list reflects the correct items in the child  
list. The problem is there is an ArrayIndexOutOfBoundsException while  
trying the submit the form. Following the trace and component source  
tells me that it is trying to retrieve an object at -1 position. I am  
not sure why.


Has anyone encountered this problem before using custom objects for  
the DynamicSelectionList component (Tap 3)? I have attached the  
source code of the page and also the stack trace. Please let me know  
if there's anything you need to figure out this problem. Thanks.


-waimun

/* start of source */

public abstract class AddReferral extends BasePage implements
PageRenderListener {

public abstract UserDepartmentDao getUserDepartmentDao();

public abstract IPropertySelectionModel getDepartmentSelectionModel();

public abstract void setDepartmentSelectionModel(
IPropertySelectionModel selectionModel);

public abstract UserAccountDao getUserAccountDao();

public abstract List getUsersByDepartmentList();

public abstract void setUsersByDepartmentList(List users);

public void pageBeginRender(PageEvent event) {

List allDepartments = getUserDepartmentDao().findAll();

if (getDepartmentSelectionModel() == null) {
setDepartmentSelectionModel(new 
DepartmentSelectionModel(
allDepartments));
}

// get users by department from the department selection model.

		DepartmentSelectionModel deptModel = (DepartmentSelectionModel)  
getDepartmentSelectionModel();


for (Iterator it = deptModel.getDepartmentList().iterator(); it
.hasNext();) {

List usersByDepartment = null;

UserDepartment d = (UserDepartment) it.next();

usersByDepartment = 
getUserAccountDao().findByDepartment(d);

getUsersByDepartmentList().add(
new 
UsersByDepartmentSelectionModel(usersByDepartment));

}

}

}

/* end of source */

/*
Stack Trace:

* java.util.ArrayList.get(ArrayList.java:323)
*  
man.library.components.dynamicSelectionList.DynamicSelectionList.getChil 
dModel(DynamicSelectionList.java:309)
*  
man.library.components.dynamicSelectionList.DynamicSelectionList.updateV 
alue(DynamicSelectionList.java:189)
*  
man.library.components.dynamicSelectionList.DynamicSelectionList.renderC 
omponent(DynamicSelectionList.java:126)
* org.apache.tapestry.AbstractComponent.render 
(AbstractComponent.java:857)
* org.apache.tapestry.AbstractComponent.renderBody 
(AbstractComponent.java:624)

* org.apache.tapestry.form.Form.renderComponent(Form.java:362)
* org.apache.tapestry.AbstractComponent.render 
(AbstractComponent.java:857)

* org.apache.tapestry.form.Form.rewind(Form.java:568)
* org.apache.tapestry.engine.RequestCycle.rewindForm 
(RequestCycle.java:432)

* org.apache.tapestry.form.Form.trigger(Form.java:582)
* org.apache.tapestry.engine.DirectService.service 
(DirectService.java:169)
* org.apache.tapestry.engine.AbstractEngine.service 
(AbstractEngine.java:889)
* org.apache.tapestry.ApplicationServlet.doService 
(ApplicationServlet.java:198)
* org.apache.tapestry.ApplicationServlet.doPost 
(ApplicationServlet.java:327)

* javax.servlet.http.HttpServlet.service(HttpServlet.java:154)
* javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
* com.caucho.server.dispatch.ServletFilterChain.doFilter 
(ServletFilterChain.java:99)
* com.caucho.server.webapp.WebAppFilterChain.doFilter 
(WebAppFilterChain.java:163)
* com.caucho.server.dispatch.ServletInvocation.service 
(ServletInvocation.java:208)
* com.caucho.server.http.HttpRequest.handleRequest 
(HttpRequest.java:259)

* com.caucho.server.port.TcpConnection.run(TcpConnection.java:363)
* com.caucho.util.ThreadPool.runTasks(ThreadPool.java:490)
* com.caucho.util.ThreadPool.run(ThreadPool.java:423)
* java.lang.Thread.run(Thread.java:613)

*/



Re: Auto-updating a drop-down list

2006-08-02 Thread Waimun Yeow

Jesse and Nick,

Thanks for the suggestions (1) EventListener (2) DynamicSelectionList.

I am currently using Tap 3.03 and perhaps this is a good chance to  
upgrade if I want to take advantage of 4.1 features. But I am  
concerned whether if I need to make a lot of changes to the way I  
configured the application to integrate Spring with Tapestry in  
section 15.4.2.3 at  (http://www.springframework.org/docs/reference/ 
webintegration.html).


The DynamicSelectionList is also a good option since you said it  
works with T3 (with tweaks). Perhaps you can point me to an example  
and also provide the tweaks in order for it to work.



Thanks,
waimun

Override window.onload function

2006-05-11 Thread Waimun Yeow
Hi.

I am using the default @DatePicker in one of the html pages where I have a
window.onload function declared in the head tags.

Since using @DatePicker requires @Body, my window.onload function is
replaced by the DatePicker script that initializes the javascript calendar
object.

1. How do I append my onload function to the onload function added by the
DatePicker?

2. Also, how do I also specify a different format (MM/dd/yy) for the date
instead of the default (dd MMM ).


Thanks,

waimun

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]