You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Mihir Solanki <mi...@patni.com> on 2005/04/25 16:36:20 UTC

submitting tree2 node to a serlvet

Hi,

 

I am using tree2 component.

 

I have a kind of windows explorer UI, where in my tree nodes are formed with
folders, sub-folders and files.

For the same I have three different facets like "folder", "sub-folder" and
"document" in my tree2 component.

 

Now what I want to have is, whenever "document" type node is clicked I have
to open that particular document in my browser window.

For that I guess I need to submit my action to the HttpServlet which reads
the file data and opens in the browser window (by putting file data in the
Servlet stream).

 

Can anybody tell me how can I submit the click action of any tree node to
HttpServlet?

Or is there any other way to achieve the above kind of functionality?

 

Thanks

Mihir Solanki

  _____  

Patni Computer Systems Ltd.

Tel : 91 79 23240905 Ext : 413

 


http://www.patni.com
World-Wide Partnerships. World-Class Solutions.
_____________________________________________________________________

This e-mail message may contain proprietary, confidential or legally
privileged information for the sole use of the person or entity to
whom this message was originally addressed. Any review, e-transmission
dissemination or other use of or taking of any action in reliance upon
this information by persons or entities other than the intended
recipient is prohibited. If you have received this e-mail in error
kindly delete  this e-mail from your records. If it appears that this
mail has been forwarded to you without proper authority, please notify
us immediately at netadmin@patni.com and delete this mail. 
_____________________________________________________________________

Re: submitting tree2 node to a serlvet

Posted by Rob Decker <ro...@objectsource.org>.
Have you tried using a plain old outputLink that targets the frame? I've
been thinking about trying to just use the tree in a struts app and if I
could put it in  a frame and link to my jsp from it I'd probably save alot
of time.


----- Original Message ----- 
From: "Mihir Solanki" <mi...@patni.com>
To: "'MyFaces Discussion'" <us...@myfaces.apache.org>; "'Sean Schofield'"
<se...@gmail.com>; "'Enrique Medina'" <e....@gmail.com>
Sent: Wednesday, April 27, 2005 4:32 AM
Subject: RE: submitting tree2 node to a serlvet


Sean / Enrique

Actually in my case I have two html frames. In left frame I have a tree and
I right side frame I need to open the selected document (from tree).

Now my only concern is how to call a servlet when I click on document type
node
and hence I can open the document in right frame (I know the code of
streaming the document content).

If possible please guide me with some code snippest...

Below is my code snippet of JSF

<f:facet name="folder">
<h:panelGroup>
<h:commandLink immediate="true" style="text-decoration:
none;" action="#{t.toggleExpanded}"
actionListener="#{CabinetTree.processAction}">

<h:graphicImage value="/images/blue-folder-open.gif"
align="middle" rendered="#{t.nodeExpanded}"
border="0"/>
<h:graphicImage
value="/images/blue-folder-closed.gif"
align="middle" rendered="#{!t.nodeExpanded}"
border="0"/>
<h:outputText value="#{node.description}"
styleClass="nodeTree"/>
<h:outputText value=" (#{node.childCount})"
styleClass="childCount" rendered="#{!empty
node.children}"/>
</h:commandLink>
</h:panelGroup>
</f:facet>
<f:facet name="document">
<h:panelGroup>
<h:commandLink immediate="true" style="text-decoration:
none;" target="contents" action="test.jsp">

<h:graphicImage value="/images/document.gif"
align="middle" border="0"/>

<h:outputText value="#{node.description}"
styleClass="nodeTree"/>

</h:commandLink>
</h:panelGroup>
</f:facet>

-----Original Message-----
From: Sean Schofield [mailto:sean.schofield@gmail.com]
Sent: Monday, April 25, 2005 9:37 PM
To: MyFaces Discussion; Enrique Medina
Subject: Re: submitting tree2 node to a serlvet

You can also have a param whose value is the node identifier.   That
is one of the uses I had envisioned for the identifier property (use
the documnet number as the node identifier.)  Then just have your
command link point you to the servlet.

I think this is one of the cool parts of tree2.  It is very
open-ended.  You just use the standard approaches that work in other
situations.  So there is nothing special about tree2 that you need to
know here.  Take the same approach that you would with h:dataTable.

sean


On 4/25/05, Enrique Medina <e....@gmail.com> wrote:
> Hi,
>
> First you have to create the tree data (see getTreeData() method from
> the examples) passing an extra parameter to the TreeNodeBase
> constructor, in order to give each node an identifier (I have given
> the page to navigate to, for example).
>
> Then, indicate in the action of the commandLink component the following:
>
>         <f:facet name="document">
>                 <x:panelGroup>
>                         <x:commandLink immediate="true"
action="#{myBean.menuAction}">
>                                 <h:graphicImage
value="images/document.png" border="0" />
>                                 <x:outputText value="#{node.description}"
/>
>                                 <f:param name="action"
value="#{node.identifier}" />
>                         </x:commandLink>
>                 </x:panelGroup>
>         </f:facet>
>
> As you can see, you will have to define a method in your "myBean" bean
> in order to be able to execute the action:
>
> public String menuAction()
> {
>                 return (String)
FacesContext.getCurrentInstance().getExternalContext()
>                                 .getRequestParameterMap().get("action");
> }
>
> Notice that you ask for a request parameter named "action", which must
> match the name of the param you provided in the JSP view.
>
> In my case, this method returns the identifier of the node clicked,
> which is the page to go in the navigation model.
>
> You will only have to provide different logic to that method.
>
> Hope it helps,
> Enrique Medina.
>
> On 4/25/05, Mihir Solanki <mi...@patni.com> wrote:
> >
> >
> >
> > Hi,
> >
> >
> >
> > I am using tree2 component.
> >
> >
> >
> > I have a kind of windows explorer UI, where in my tree nodes are formed
with
> > folders, sub-folders and files.
> >
> > For the same I have three different facets like "folder", "sub-folder"
and
> > "document" in my tree2 component.
> >
> >
> >
> > Now what I want to have is, whenever "document" type node is clicked I
have
> > to open that particular document in my browser window.
> >
> > For that I guess I need to submit my action to the HttpServlet which
reads
> > the file data and opens in the browser window (by putting file data in
the
> > Servlet stream).
> >
> >
> >
> > Can anybody tell me how can I submit the click action of any tree node
to
> > HttpServlet?
> >
> > Or is there any other way to achieve the above kind of functionality?
> >
> >
> >
> > Thanks
> >
> > Mihir Solanki
> >  ________________________________
> >
> >
> >
> > Patni Computer Systems Ltd.
> >
> >
> > Tel : 91 79 23240905 Ext : 413
> >
> >
> > http://www.patni.com
> >  World-Wide Partnerships. World-Class Solutions.
> > _____________________________________________________________________
> >
> >  This e-mail message may contain proprietary, confidential or legally
> > privileged information for the sole use of the person or entity to whom
this
> > message was originally addressed. Any review, e-transmission
dissemination
> > or other use of or taking of any action in reliance upon this
information by
> > persons or entities other than the intended recipient is prohibited. If
you
> > have received this e-mail in error kindly delete this e-mail from your
> > records. If it appears that this mail has been forwarded to you without
> > proper authority, please notify us immediately at netadmin@patni.com and
> > delete this mail.
> > _____________________________________________________________________
>



http://www.patni.com
World-Wide Partnerships. World-Class Solutions.
_____________________________________________________________________

This e-mail message may contain proprietary, confidential or legally
privileged information for the sole use of the person or entity to
whom this message was originally addressed. Any review, e-transmission
dissemination or other use of or taking of any action in reliance upon
this information by persons or entities other than the intended
recipient is prohibited. If you have received this e-mail in error
kindly delete  this e-mail from your records. If it appears that this
mail has been forwarded to you without proper authority, please notify
us immediately at netadmin@patni.com and delete this mail.
_____________________________________________________________________


RE: submitting tree2 node to a serlvet

Posted by Mihir Solanki <mi...@patni.com>.
Sean / Enrique

Actually in my case I have two html frames. In left frame I have a tree and
I right side frame I need to open the selected document (from tree).

Now my only concern is how to call a servlet when I click on document type
node
and hence I can open the document in right frame (I know the code of
streaming the document content).

If possible please guide me with some code snippest...

Below is my code snippet of JSF

<f:facet name="folder">
	<h:panelGroup>
		<h:commandLink immediate="true" style="text-decoration:
none;" 			action="#{t.toggleExpanded}"
actionListener="#{CabinetTree.processAction}">
			
			<h:graphicImage value="/images/blue-folder-open.gif"
align="middle" rendered="#{t.nodeExpanded}"
border="0"/>
			<h:graphicImage
value="/images/blue-folder-closed.gif"
align="middle" rendered="#{!t.nodeExpanded}"
border="0"/>
			<h:outputText value="#{node.description}"
styleClass="nodeTree"/>
			<h:outputText value=" (#{node.childCount})"
styleClass="childCount" rendered="#{!empty
node.children}"/>
		</h:commandLink>
	</h:panelGroup>
</f:facet>
<f:facet name="document">
	<h:panelGroup>
		<h:commandLink immediate="true" style="text-decoration:
none;" 			target="contents" action="test.jsp">
			
			<h:graphicImage value="/images/document.gif"
align="middle" border="0"/>
			
			<h:outputText value="#{node.description}"
styleClass="nodeTree"/>
			
		</h:commandLink>
	</h:panelGroup>
</f:facet>

-----Original Message-----
From: Sean Schofield [mailto:sean.schofield@gmail.com] 
Sent: Monday, April 25, 2005 9:37 PM
To: MyFaces Discussion; Enrique Medina
Subject: Re: submitting tree2 node to a serlvet

You can also have a param whose value is the node identifier.   That
is one of the uses I had envisioned for the identifier property (use
the documnet number as the node identifier.)  Then just have your
command link point you to the servlet.

I think this is one of the cool parts of tree2.  It is very
open-ended.  You just use the standard approaches that work in other
situations.  So there is nothing special about tree2 that you need to
know here.  Take the same approach that you would with h:dataTable.

sean


On 4/25/05, Enrique Medina <e....@gmail.com> wrote:
> Hi,
> 
> First you have to create the tree data (see getTreeData() method from
> the examples) passing an extra parameter to the TreeNodeBase
> constructor, in order to give each node an identifier (I have given
> the page to navigate to, for example).
> 
> Then, indicate in the action of the commandLink component the following:
> 
>         <f:facet name="document">
>                 <x:panelGroup>
>                         <x:commandLink immediate="true"
action="#{myBean.menuAction}">
>                                 <h:graphicImage
value="images/document.png" border="0" />
>                                 <x:outputText value="#{node.description}"
/>
>                                 <f:param name="action"
value="#{node.identifier}" />
>                         </x:commandLink>
>                 </x:panelGroup>
>         </f:facet>
> 
> As you can see, you will have to define a method in your "myBean" bean
> in order to be able to execute the action:
> 
> public String menuAction()
> {
>                 return (String)
FacesContext.getCurrentInstance().getExternalContext()
>                                 .getRequestParameterMap().get("action");
> }
> 
> Notice that you ask for a request parameter named "action", which must
> match the name of the param you provided in the JSP view.
> 
> In my case, this method returns the identifier of the node clicked,
> which is the page to go in the navigation model.
> 
> You will only have to provide different logic to that method.
> 
> Hope it helps,
> Enrique Medina.
> 
> On 4/25/05, Mihir Solanki <mi...@patni.com> wrote:
> >
> >
> >
> > Hi,
> >
> >
> >
> > I am using tree2 component.
> >
> >
> >
> > I have a kind of windows explorer UI, where in my tree nodes are formed
with
> > folders, sub-folders and files.
> >
> > For the same I have three different facets like "folder", "sub-folder"
and
> > "document" in my tree2 component.
> >
> >
> >
> > Now what I want to have is, whenever "document" type node is clicked I
have
> > to open that particular document in my browser window.
> >
> > For that I guess I need to submit my action to the HttpServlet which
reads
> > the file data and opens in the browser window (by putting file data in
the
> > Servlet stream).
> >
> >
> >
> > Can anybody tell me how can I submit the click action of any tree node
to
> > HttpServlet?
> >
> > Or is there any other way to achieve the above kind of functionality?
> >
> >
> >
> > Thanks
> >
> > Mihir Solanki
> >  ________________________________
> >
> >
> >
> > Patni Computer Systems Ltd.
> >
> >
> > Tel : 91 79 23240905 Ext : 413
> >
> >
> > http://www.patni.com
> >  World-Wide Partnerships. World-Class Solutions.
> > _____________________________________________________________________
> >
> >  This e-mail message may contain proprietary, confidential or legally
> > privileged information for the sole use of the person or entity to whom
this
> > message was originally addressed. Any review, e-transmission
dissemination
> > or other use of or taking of any action in reliance upon this
information by
> > persons or entities other than the intended recipient is prohibited. If
you
> > have received this e-mail in error kindly delete this e-mail from your
> > records. If it appears that this mail has been forwarded to you without
> > proper authority, please notify us immediately at netadmin@patni.com and
> > delete this mail.
> > _____________________________________________________________________
>



http://www.patni.com
World-Wide Partnerships. World-Class Solutions.
_____________________________________________________________________

This e-mail message may contain proprietary, confidential or legally
privileged information for the sole use of the person or entity to
whom this message was originally addressed. Any review, e-transmission
dissemination or other use of or taking of any action in reliance upon
this information by persons or entities other than the intended
recipient is prohibited. If you have received this e-mail in error
kindly delete  this e-mail from your records. If it appears that this
mail has been forwarded to you without proper authority, please notify
us immediately at netadmin@patni.com and delete this mail. 
_____________________________________________________________________

Re: submitting tree2 node to a serlvet

Posted by Sean Schofield <se...@gmail.com>.
You can also have a param whose value is the node identifier.   That
is one of the uses I had envisioned for the identifier property (use
the documnet number as the node identifier.)  Then just have your
command link point you to the servlet.

I think this is one of the cool parts of tree2.  It is very
open-ended.  You just use the standard approaches that work in other
situations.  So there is nothing special about tree2 that you need to
know here.  Take the same approach that you would with h:dataTable.

sean


On 4/25/05, Enrique Medina <e....@gmail.com> wrote:
> Hi,
> 
> First you have to create the tree data (see getTreeData() method from
> the examples) passing an extra parameter to the TreeNodeBase
> constructor, in order to give each node an identifier (I have given
> the page to navigate to, for example).
> 
> Then, indicate in the action of the commandLink component the following:
> 
>         <f:facet name="document">
>                 <x:panelGroup>
>                         <x:commandLink immediate="true" action="#{myBean.menuAction}">
>                                 <h:graphicImage value="images/document.png" border="0" />
>                                 <x:outputText value="#{node.description}" />
>                                 <f:param name="action" value="#{node.identifier}" />
>                         </x:commandLink>
>                 </x:panelGroup>
>         </f:facet>
> 
> As you can see, you will have to define a method in your "myBean" bean
> in order to be able to execute the action:
> 
> public String menuAction()
> {
>                 return (String) FacesContext.getCurrentInstance().getExternalContext()
>                                 .getRequestParameterMap().get("action");
> }
> 
> Notice that you ask for a request parameter named "action", which must
> match the name of the param you provided in the JSP view.
> 
> In my case, this method returns the identifier of the node clicked,
> which is the page to go in the navigation model.
> 
> You will only have to provide different logic to that method.
> 
> Hope it helps,
> Enrique Medina.
> 
> On 4/25/05, Mihir Solanki <mi...@patni.com> wrote:
> >
> >
> >
> > Hi,
> >
> >
> >
> > I am using tree2 component.
> >
> >
> >
> > I have a kind of windows explorer UI, where in my tree nodes are formed with
> > folders, sub-folders and files.
> >
> > For the same I have three different facets like "folder", "sub-folder" and
> > "document" in my tree2 component.
> >
> >
> >
> > Now what I want to have is, whenever "document" type node is clicked I have
> > to open that particular document in my browser window.
> >
> > For that I guess I need to submit my action to the HttpServlet which reads
> > the file data and opens in the browser window (by putting file data in the
> > Servlet stream).
> >
> >
> >
> > Can anybody tell me how can I submit the click action of any tree node to
> > HttpServlet?
> >
> > Or is there any other way to achieve the above kind of functionality?
> >
> >
> >
> > Thanks
> >
> > Mihir Solanki
> >  ________________________________
> >
> >
> >
> > Patni Computer Systems Ltd.
> >
> >
> > Tel : 91 79 23240905 Ext : 413
> >
> >
> > http://www.patni.com
> >  World-Wide Partnerships. World-Class Solutions.
> > _____________________________________________________________________
> >
> >  This e-mail message may contain proprietary, confidential or legally
> > privileged information for the sole use of the person or entity to whom this
> > message was originally addressed. Any review, e-transmission dissemination
> > or other use of or taking of any action in reliance upon this information by
> > persons or entities other than the intended recipient is prohibited. If you
> > have received this e-mail in error kindly delete this e-mail from your
> > records. If it appears that this mail has been forwarded to you without
> > proper authority, please notify us immediately at netadmin@patni.com and
> > delete this mail.
> > _____________________________________________________________________
>

Re: submitting tree2 node to a serlvet

Posted by Enrique Medina <e....@gmail.com>.
Hi,

First you have to create the tree data (see getTreeData() method from
the examples) passing an extra parameter to the TreeNodeBase
constructor, in order to give each node an identifier (I have given
the page to navigate to, for example).

Then, indicate in the action of the commandLink component the following:

	<f:facet name="document">
		<x:panelGroup>
			<x:commandLink immediate="true" action="#{myBean.menuAction}">
				<h:graphicImage value="images/document.png" border="0" />
				<x:outputText value="#{node.description}" />
				<f:param name="action" value="#{node.identifier}" />
			</x:commandLink>
		</x:panelGroup>
	</f:facet>

As you can see, you will have to define a method in your "myBean" bean
in order to be able to execute the action:

public String menuAction()
{
		return (String) FacesContext.getCurrentInstance().getExternalContext()
				.getRequestParameterMap().get("action");
}

Notice that you ask for a request parameter named "action", which must
match the name of the param you provided in the JSP view.

In my case, this method returns the identifier of the node clicked,
which is the page to go in the navigation model.

You will only have to provide different logic to that method.

Hope it helps,
Enrique Medina.

On 4/25/05, Mihir Solanki <mi...@patni.com> wrote:
>  
>  
> 
> Hi, 
> 
>   
> 
> I am using tree2 component. 
> 
>   
> 
> I have a kind of windows explorer UI, where in my tree nodes are formed with
> folders, sub-folders and files. 
> 
> For the same I have three different facets like "folder", "sub-folder" and
> "document" in my tree2 component. 
> 
>   
> 
> Now what I want to have is, whenever "document" type node is clicked I have
> to open that particular document in my browser window. 
> 
> For that I guess I need to submit my action to the HttpServlet which reads
> the file data and opens in the browser window (by putting file data in the
> Servlet stream). 
> 
>   
> 
> Can anybody tell me how can I submit the click action of any tree node to
> HttpServlet? 
> 
> Or is there any other way to achieve the above kind of functionality? 
> 
>   
> 
> Thanks 
> 
> Mihir Solanki 
>  ________________________________
>  
>  
> 
> Patni Computer Systems Ltd. 
>  
> 
> Tel : 91 79 23240905 Ext : 413 
> 
>   
> http://www.patni.com
>  World-Wide Partnerships. World-Class Solutions. 
> _____________________________________________________________________
>  
>  This e-mail message may contain proprietary, confidential or legally
> privileged information for the sole use of the person or entity to whom this
> message was originally addressed. Any review, e-transmission dissemination
> or other use of or taking of any action in reliance upon this information by
> persons or entities other than the intended recipient is prohibited. If you
> have received this e-mail in error kindly delete this e-mail from your
> records. If it appears that this mail has been forwarded to you without
> proper authority, please notify us immediately at netadmin@patni.com and
> delete this mail. 
> _____________________________________________________________________