Re: tomahawk tree2 for clay built up tree structure

2006-07-13 Thread stephan opitz

thx

2006/7/13, Gary VanMatre [EMAIL PROTECTED]:

From: stephan opitz [EMAIL PROTECTED]

 problem is the structure.

 if i have an object containing an id and a parentId (which is null, or
 linking to another object - the parent one)

 if i get a list from db how is it possible to build up the structure
 for the tree2

 i tried hashmap or recursive algorithm, but nothing with much success...

 any ideas


You might consider the following code snippet.


public class TreeBacker {

   public TreeNode findNode(TreeNode root, Integer sarg) {
   Integer id = root.getDescription() == null ? null : new 
Integer(root.getDescription());
   if (compare(id, sarg) == 0) {
   return root;
   }
   Iterator ci = root.getChildren().iterator();
   while (ci.hasNext()) {
   TreeNode found = findNode((TreeNode) ci.next(), sarg);
   if (found != null)
   return found;
   }

   return null;
   }


   public TreeNode getTreeData() {

   TreeNode root = new TreeNodeBase(root, null, false);
   TreeNode current = root; // current root

   Collection dbRows = getDBRows();
   Iterator di = dbRows.iterator();
   while (di.hasNext()) {
   MyVO vo = (MyVO) di.next();

   Integer id = current.getDescription() == null ? null : new 
Integer(current.getDescription());
   int order = compare(id, vo.getParent());

   if (order != 0) {
   current = findNode(root, vo.getParent());
   // if current is null you have an orphaned node
   }

   String type = vo.getParent() == null ? null : 
vo.getParent().toString();
   String desc = vo.getId() == null ? null : vo.getId().toString();

   current.getChildren().add(new TreeNodeBase(type, desc, false));
   }

   return root;
   }




   public Collection getDBRows() {

   // select parent, id from table order by parent, id

   // null, 1
   // null, 2
   // null, 3
   // 1, 4
   // 1, 5
   // 2, 6
   // 2, 7
   // 3, 8
   // 3, 9
   // 9, 10
   // 9, 11

   Set sortedList = new TreeSet();
   sortedList.add(new MyVO(null, new Integer(1)));
   sortedList.add(new MyVO(new Integer(1), new Integer(4)));
   sortedList.add(new MyVO(new Integer(1), new Integer(5)));

   sortedList.add(new MyVO(null, new Integer(2)));
   sortedList.add(new MyVO(new Integer(2), new Integer(6)));
   sortedList.add(new MyVO(new Integer(2), new Integer(7)));

   sortedList.add(new MyVO(null, new Integer(3)));
   sortedList.add(new MyVO(new Integer(3), new Integer(8)));
   sortedList.add(new MyVO(new Integer(3), new Integer(9)));

   sortedList.add(new MyVO(new Integer(9), new Integer(10)));
   sortedList.add(new MyVO(new Integer(9), new Integer(11)));


   return sortedList;
   }

   class MyVO implements Comparable {


   private Integer parent = null;
   private Integer id = null;

   public MyVO(Integer parent, Integer id) {
   this.parent = parent;
   this.id = id;
   }
   public Integer getId() {
   return id;
   }
   public void setId(Integer id) {
   this.id = id;
   }
   public Integer getParent() {
   return parent;
   }
   public void setParent(Integer parent) {
   this.parent = parent;
   }


   public int compareTo(Object obj) {

   MyVO vo = (MyVO) obj;
   int order = compare(parent, vo.parent);
   if (order == 0)
   order = compare(id, vo.id);

   return order;
   }

   }


   public static int compare(Integer col1, Integer col2) {

   if ((col1 == null)  (col2 == null))
   return 0;
   else if ((col1 == null)  (col2 != null))
   return -1;
   else if ((col2 == null)  (col1 != null))
   return 1;
   else
   return ((Comparable) col1).compareTo(col2);
   }



   public static void main(String[] args) {
   TreeBacker backer = new TreeBacker();
   TreeNode root = backer.getTreeData();

   }


}


 stephan

Gary



Re: Shale logo contest

2006-07-13 Thread James Mitchell

The info for submitting is on our wiki...

 http://wiki.apache.org/shale/LogoContest


--
James Mitchell




On Jul 13, 2006, at 4:39 AM, Mikael Andersson wrote:


Hi,
just joined this mailing list a couple of days ago, and wonder if  
there has
been any information regarding the contest posted ( a graphics guy  
at work

seems interested).

Thanks
Mike




RE: Is this possible to pass dynamically information from a beans as a shale method parameter?

2006-07-13 Thread Iakouchev Alexander-EAL027C
Some notes. I forget to tell.

It is perfectly working with constans ...
s:validatorVar name=operationID value=Testing/

,not with beans ...
s:validatorVar name=operationID
value=#{mtJobOperation.operationID}/

Second line pass to a custom validator method just a null.
Alex.






 

-Original Message-
From: Iakouchev Alexander-EAL027C 
Sent: Thursday, July 13, 2006 10:29 AM
To: user@shale.apache.org
Subject: RE: Is this possible to pass dynamically information from a
beans as a shale method parameter?

Hello Craig!
Thank you for feedback.

I want to be more specific. I need validate all rows in dataTable
component. JSP page show list of Foo objects. For example, the
inputText component with id=--- has shale custom validate. I need
analyze dependency component id=--- row i from component id=--- row
0...n.

In other words I need pass some current row id to get by id real object.
s:commonsValidator
  type=validateQuoteHoursValue
  arg=quoteHours
  server=true
  client=false

  s:validatorVar name=operationID
value=#{mtJobOperation.operationID}/
/s:commonsValidator

This valuator does not works. It receive operationID equal null. But
outputText shown some not null information.
t:outputText value=#{mtJobOperation.operationID}/

The Shale validator example show some solution with dynamic shale method
parameter, but it is with standard validator example not a custom
validator.
Alex.













 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Craig
McClanahan
Sent: Wednesday, July 12, 2006 7:45 PM
To: user@shale.apache.org
Subject: Re: Is this possible to pass dynamically information from a
beans as a shale method parameter?

On 7/12/06, Iakouchev Alexander-EAL027C [EMAIL PROTECTED] wrote:

 Is this possible to pass dynamically information from a beans as a 
 shale method parameter?
 Alex.



In JSF 1.1, you cannot do this (it's not a Shale issue, it's the basic
functionality of JSF method binding expression).  In JSF 1.2, you can
...
but only for calls to static methods.

A better general strategy is to invoke a method that takes no
parameters, but ensure that the called method can extract whatever it
needs.  For example, consider the standard JSF call to your action
method (which takes no parameters).  There are at least two ways for the
called method to access request parameters on the incoming request:

* Via JSF programmatic APIs:

// Retrieve the value of the foo parameter
FacesContext context = FacesContext.getCurrentInstance();
String foo = (String)
 
context.getExternalContext().getRequestParameterMap().get(foo0;

* By managed beans expression evaluation.  This example requires
  a bit more setup to configure, but is much easier to use because
  the values are injected for you.  Consider again that you want to
  extract the value of the foo parameter and use it in your myAction()
  action method.  Define your managed bean entry like this:

managed-bean
  managed-bean-namemybean/managed-bean-name
  managed-bean-classcom.mypackage.MyBean/managed-bean-class
  managed-bean-scoperequest/managed-bean-scope
  managed-property
property-namefoo/property-name
value#{param.foo}/value
  /managed-property
/managed-bean

  and set up your bean class like this:

package com.mypackage;
public class MyBean {
  ...
  private String foo = null;
  public String getFoo() { return this.foo; }
  public void setFoo(String foo) { this.foo = foo; }
  ...
  public String myAction() {
// Get the value of the foo request parameter
String foo = getFoo();
...
  }
  ...
}

The formula #{param.foo} is evaluated when the managed bean is created,
and extracts the value of the request parameter named foo and calls
setFoo() on your bean.  By the time the action method is called, the
value will be there already.

Craig


Re: Shale logo contest

2006-07-13 Thread Mikael Andersson

I know, had a look there already, and it said to check the mailing list for
more information :)

What I am most interested in knowing is the deadline ( if there is any ).

Thanks
Mike

On 13/07/06, James Mitchell [EMAIL PROTECTED] wrote:


The info for submitting is on our wiki...

  http://wiki.apache.org/shale/LogoContest


--
James Mitchell




On Jul 13, 2006, at 4:39 AM, Mikael Andersson wrote:

 Hi,
 just joined this mailing list a couple of days ago, and wonder if
 there has
 been any information regarding the contest posted ( a graphics guy
 at work
 seems interested).

 Thanks
 Mike




Re: Custom component with childrens

2006-07-13 Thread James Mitchell
Assuming you are using JSP, how are using this on your page?  With  
your own taglib or binding to an existing instance?  If you are  
simply binding a standard HtmlPanelGrid and then declaring child  
components, you will need to bind any nested components as well.



--
James Mitchell




On Jul 13, 2006, at 10:01 AM, David Delbecq wrote:


Hello all,

Starting to learn JSF, i tried to create my custom UI component.  
Because

it will be made of several fields and button, i decided to extends
HTMLPanelGrid. The constructor creates the various components part of
the Panel. After getting funny errors in console, i worked on a step
by step and noticed in restore view, myfaces does inject childs in my
component (so the number of child is double: those created at
intanciation of my component and those saved from previous instance  
and

injected as part of restore view).

My question is, considering the way i do it for now (which is  
bad ;) ),

what is the best way to avoid this restore view problem. How can my
component know if it is in a state where it need to create itself it's
children or in a state where the controller will restore the children
tree itself?

Thank for help.

public class HTMLAddressComponent extends HtmlPanelGrid implements
NamingContainer {
.

public HTMLAddressComponent(){
street = new HtmlInputText();
number = new HtmlInputText();
town = new HtmlInputText();
postCode = new HtmlInputText();
command = new HtmlCommandButton();
command.setValue(enable/disable);
street.setId(street);
number.setId(number);
town.setId(town);
postCode.setId(postCode);
command.setId(command);
List childs = getChildren();
HtmlPanelGroup group = new HtmlPanelGroup();
List l = group.getChildren();
l.add(getText(Street: ));
l.add(street);
l.add(getText(Number: ));
l.add(number);
childs.add(group);
group = new HtmlPanelGroup();
l = group.getChildren();
l.add(getText(postcode: ));
l.add(postCode);
l.add(getText(Town: ));
l.add(town);
childs.add(group);
childs.add(command);
}
private UIComponent getText(String value){
HtmlOutputText text = new HtmlOutputText();
text.setValue(value);
return text;
}







Re: Shale logo contest

2006-07-13 Thread James Mitchell
Aug 31 was proposed on the dev list.  Any chance you'd like to join  
that list (if not already) and help us decide?


--
James Mitchell




On Jul 13, 2006, at 11:30 AM, Mikael Andersson wrote:

I know, had a look there already, and it said to check the mailing  
list for

more information :)

What I am most interested in knowing is the deadline ( if there is  
any ).


Thanks
Mike

On 13/07/06, James Mitchell [EMAIL PROTECTED] wrote:


The info for submitting is on our wiki...

  http://wiki.apache.org/shale/LogoContest


--
James Mitchell




On Jul 13, 2006, at 4:39 AM, Mikael Andersson wrote:

 Hi,
 just joined this mailing list a couple of days ago, and wonder if
 there has
 been any information regarding the contest posted ( a graphics guy
 at work
 seems interested).

 Thanks
 Mike






Re: Custom component with childrens

2006-07-13 Thread delbd
Am playing with jsf and  learning ^^ (got example doing new HtmlXXX from
sun's forum)
for the tutorials, if you have good references i'll be happy to read
them, i couldn't find anything that went further than just creating html
elements inside the renderer (nothing about creating composite elements
for example). And i still need a bit of time to read the full 300 pages
jsf specs  ^^ :)


Btw am still  trying to find how to connect the 'command' to the bean
'someAction' method, because the bean is the result of evaluation of my
custom component 'value' and i bet if my custom component is invoked
like this
customLib:customComponent value=#{myBean.myProperty}/ and i try to
generate a method binding for command action using such an expression
'#{#{myBean.myProperty}.someAction}' this will probably fail :)

Thanks for your time,
David Delbecq

James Mitchell a écrit :

 I see, sorry I wasn't paying attention to your constructor.


 Try creating your components with something like this...


 ...
 ...

 street = createHtmlInputText(street);
 number = createHtmlInputText(number);
 town = createHtmlInputText(town);
 postCode = createHtmlInputText(postCode);
 command = createHtmlCommandButton(command);

 ...
 ...
 }

 protected HtmlInputText createHtmlInputText(String id) {
 Application application = FacesContext.getCurrentInstance
 ().getApplication();

 HtmlInputText intput =
 (HtmlInputText)application.createComponent
 (HtmlInputText.COMPONENT_TYPE);
 input.setId(id);
 return input;
 }
 protected HtmlInputText createHtmlCommandButton(String id) {
 Application application = FacesContext.getCurrentInstance
 ().getApplication();
 ...
 ...




 The problem is in how you are creating new components.  It isn't 
 enough just to do new HtmlXXX(), you must create them with the 
 createComponent method.  There's a few things going on under the 
 covers with respect to how JSF deals with components.  You might also 
 think about getting a good book or referencing a tutorial while 
 building your app.  There's a lot more to JSF than meets the eye.


 -- 
 James Mitchell




 On Jul 13, 2006, at 2:44 PM, delbd wrote:

 No, am creating a JSF component on it's own (with it's own tag), 
 like this
 mytaglib:mycomponent id=someId value=#{myBean}/


 James Mitchell a écrit :

 Assuming you are using JSP, how are using this on your page?  With
 your own taglib or binding to an existing instance?  If you are
 simply binding a standard HtmlPanelGrid and then declaring child
 components, you will need to bind any nested components as well.


 -- 
 James Mitchell




 On Jul 13, 2006, at 10:01 AM, David Delbecq wrote:

 Hello all,

 Starting to learn JSF, i tried to create my custom UI component.
 Because
 it will be made of several fields and button, i decided to extends
 HTMLPanelGrid. The constructor creates the various components  part of
 the Panel. After getting funny errors in console, i worked on a 
 step
 by step and noticed in restore view, myfaces does inject childs  in my
 component (so the number of child is double: those created at
 intanciation of my component and those saved from previous 
 instance  and
 injected as part of restore view).

 My question is, considering the way i do it for now (which is   bad
 ;) ),
 what is the best way to avoid this restore view problem. How can my
 component know if it is in a state where it need to create itself 
 it's
 children or in a state where the controller will restore the  children
 tree itself?

 Thank for help.

 public class HTMLAddressComponent extends HtmlPanelGrid implements
 NamingContainer {
 .

 public HTMLAddressComponent(){
 street = new HtmlInputText();
 number = new HtmlInputText();
 town = new HtmlInputText();
 postCode = new HtmlInputText();
 command = new HtmlCommandButton();
 command.setValue(enable/disable);
 street.setId(street);
 number.setId(number);
 town.setId(town);
 postCode.setId(postCode);
 command.setId(command);
 List childs = getChildren();
 HtmlPanelGroup group = new HtmlPanelGroup();
 List l = group.getChildren();
 l.add(getText(Street: ));
 l.add(street);
 l.add(getText(Number: ));
 l.add(number);
 childs.add(group);
 group = new HtmlPanelGroup();
 l = group.getChildren();
 l.add(getText(postcode: ));
 l.add(postCode);
 l.add(getText(Town: ));
 l.add(town);
 childs.add(group);
 childs.add(command);
 }
 private UIComponent getText(String value){
 HtmlOutputText text = new HtmlOutputText();
 text.setValue(value);
 return text;
 }










Re: tomahawk tree2 for clay built up tree structure

2006-07-13 Thread stephan opitz

i will do it next days

2006/7/13, Matthias Wessendorf [EMAIL PROTECTED]:

Stephan,

can you put that to the wiki ?

On 7/13/06, stephan opitz [EMAIL PROTECTED] wrote:
 thx

 2006/7/13, Gary VanMatre [EMAIL PROTECTED]:
  From: stephan opitz [EMAIL PROTECTED]
  
   problem is the structure.
  
   if i have an object containing an id and a parentId (which is null, or
   linking to another object - the parent one)
  
   if i get a list from db how is it possible to build up the structure
   for the tree2
  
   i tried hashmap or recursive algorithm, but nothing with much success...
  
   any ideas
  
 
  You might consider the following code snippet.
 
 
  public class TreeBacker {
 
 public TreeNode findNode(TreeNode root, Integer sarg) {
 Integer id = root.getDescription() == null ? null : new 
Integer(root.getDescription());
 if (compare(id, sarg) == 0) {
 return root;
 }
 Iterator ci = root.getChildren().iterator();
 while (ci.hasNext()) {
 TreeNode found = findNode((TreeNode) ci.next(), sarg);
 if (found != null)
 return found;
 }
 
 return null;
 }
 
 
 public TreeNode getTreeData() {
 
 TreeNode root = new TreeNodeBase(root, null, false);
 TreeNode current = root; // current root
 
 Collection dbRows = getDBRows();
 Iterator di = dbRows.iterator();
 while (di.hasNext()) {
 MyVO vo = (MyVO) di.next();
 
 Integer id = current.getDescription() == null ? null : new 
Integer(current.getDescription());
 int order = compare(id, vo.getParent());
 
 if (order != 0) {
 current = findNode(root, vo.getParent());
 // if current is null you have an orphaned node
 }
 
 String type = vo.getParent() == null ? null : 
vo.getParent().toString();
 String desc = vo.getId() == null ? null : vo.getId().toString();
 
 current.getChildren().add(new TreeNodeBase(type, desc, false));
 }
 
 return root;
 }
 
 
 
 
 public Collection getDBRows() {
 
 // select parent, id from table order by parent, id
 
 // null, 1
 // null, 2
 // null, 3
 // 1, 4
 // 1, 5
 // 2, 6
 // 2, 7
 // 3, 8
 // 3, 9
 // 9, 10
 // 9, 11
 
 Set sortedList = new TreeSet();
 sortedList.add(new MyVO(null, new Integer(1)));
 sortedList.add(new MyVO(new Integer(1), new Integer(4)));
 sortedList.add(new MyVO(new Integer(1), new Integer(5)));
 
 sortedList.add(new MyVO(null, new Integer(2)));
 sortedList.add(new MyVO(new Integer(2), new Integer(6)));
 sortedList.add(new MyVO(new Integer(2), new Integer(7)));
 
 sortedList.add(new MyVO(null, new Integer(3)));
 sortedList.add(new MyVO(new Integer(3), new Integer(8)));
 sortedList.add(new MyVO(new Integer(3), new Integer(9)));
 
 sortedList.add(new MyVO(new Integer(9), new Integer(10)));
 sortedList.add(new MyVO(new Integer(9), new Integer(11)));
 
 
 return sortedList;
 }
 
 class MyVO implements Comparable {
 
 
 private Integer parent = null;
 private Integer id = null;
 
 public MyVO(Integer parent, Integer id) {
 this.parent = parent;
 this.id = id;
 }
 public Integer getId() {
 return id;
 }
 public void setId(Integer id) {
 this.id = id;
 }
 public Integer getParent() {
 return parent;
 }
 public void setParent(Integer parent) {
 this.parent = parent;
 }
 
 
 public int compareTo(Object obj) {
 
 MyVO vo = (MyVO) obj;
 int order = compare(parent, vo.parent);
 if (order == 0)
 order = compare(id, vo.id);
 
 return order;
 }
 
 }
 
 
 public static int compare(Integer col1, Integer col2) {
 
 if ((col1 == null)  (col2 == null))
 return 0;
 else if ((col1 == null)  (col2 != null))
 return -1;
 else if ((col2 == null)  (col1 != null))
 return 1;
 else
 return ((Comparable) col1).compareTo(col2);
 }
 
 
 
 public static void main(String[] args) {
 TreeBacker backer = new TreeBacker();
 TreeNode root = backer.getTreeData();
 
 }
 
 
  }
 
 
   stephan
 
  Gary
 



--
Matthias Wessendorf

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com