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-22 Thread Waimun Yeow
Thank you so much, Shing. The problem was indeed with object equality  
in Java. I implemented the methods and now I'm able to retrieve the  
values of the model objects on submit.


And thanks Nick, for pointing me to the correct implementation of  
using the selection models with custom objects.


Your help is very much appreciated. I am currently using the Dynamic  
Selection List instead of the standard PropertySelection.


-waimun

On 8/18/06, Shing Hing Man <[EMAIL PROTECTED]> wrote:
> You might like to try  to implemented your own equal
> method in   UserDepartment.java.
>
> Shing
>
>
>
> --- Waimun Yeow <[EMAIL PROTECTED]> wrote:
>
> > 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  > 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]



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   
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]



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


type="project6.model.UserDepartment"

persistent="no" />



		type="org.apache.tapestry.form.IPropertySelectionModel"  
persistent="no" />







global.getApplicationContext().getBean("userDepartmentDao")



global.getApplicationContext().getBean("userAccountDao")



















/* 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(Integer.parseInt(index));
}

public List getUsersList() {
return usersList;
}

}

public class DepartmentSelectionModel implements  
IPropertySelectionModel, Serializable {


private List departmentList = new ArrayList();

private static UserDepartmentDao dao;

public DepartmentSelectionModel() {

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

dao = (UserDepartmentDao) factory.getBean("userDepartmentDao");
}

public DepartmentSelectionModel(List depts) {

this();

if (depts == null)
return;

departmentList = depts;
}

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

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

public String getLabel(int index) 

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/viewComponent&sp=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-03 Thread Waimun Yeow

Hi Nick,

Thanks for the link. I found it yesterday while I was hunting for the  
link to download the component. By the way, I also found AnySubmit  
component, which I think I am going to use it for another problem. I  
am going to work on the DSL and will let you know if I stumble on any  
problems.


-waimun



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



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

Auto-updating a drop-down list

2006-08-01 Thread Waimun Yeow

Hi,

I would like to find out how I can auto-update a drop down list in a  
form when another drop down list changes. For example, in a HTML  
form, I have two  elements. Let's say the first  has  
a list of department names and upon selecting one, it updates the  
second  with a list of employees for the selected department.  
Also, the values of the two  elements are retrieved from a  
database table.


What is the typical approach of dealing with this type of problem? Is  
there any article that explains this? I would appreciate if anyone  
who has dealt with a similar problem above provide me with  some  
suggestions or pointers. Thanks.


-waimun

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



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  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]