[Logo] OLD FORUM - Use new one: https://www.CaptainCasa.online/forum
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
popup menu and rowinclude/contentreplace  XML
Forum Index -> Development
Author Message
bthalheim

Power User

Joined: 05/04/2012 11:45:24
Messages: 72
Offline

Hello,

I have several Grids in in page, each of which has an Icon for GridBinding#textSearcher#onPrevious, GridBinding#textSearcher#onNext, a field for GridBinding#textSearcher#text plus an icon pointing to GridBinding#onEditColumnDetails.

I put this into a JSP which I can rowinclude into another JSP. My searchAndChooseColumns.jsp looks like this:
Code:
 	<t:row id="g_1" >
 	<t:icon id="g_2" actionListener="#{PATHTOGRIDBINDING.textSearcher.onPrevious}" image="/eclntjsfserver/images/control_playbackwards.png" />
 	<t:field id="g_3" actionListener="#{PATHTOGRIDBINDING.textSearcher.onNext}" bgpaint="image(100%-5,50%,/images/icons/magnifier.png,rightmiddle)" enabled="true" flush="true" selectallwhenfocussed="true" tabonenter="true" tabonenteralwaysflush="true" text="#{PATHTOGRIDBINDING.textSearcher.text}" textimage="/eclntjsfserver/images/magnifier.png" width="100" />
 	<t:icon id="g_4" actionListener="#{PATHTOGRIDBINDING.textSearcher.onNext}" image="/eclntjsfserver/images/control_play.png" />
 	<t:coldistance id="g_5" width="100%" />
 	<t:icon id="g_6" actionListener="#{PATHTOGRIDBINDING.onEditColumnDetails}" image="/eclntjsfserver/images/table.png" />
 	</t:row>


The page which rowincludes this does the following:
<t:rowinclude id="g_13" contentreplace="PATHTOGRIDBINDING:d.VorgangsEditorUI.vorgaenge" page="/util/searchAndChooseColumns.jsp" />

Very fine so far.

What I had before I extracted the common code into a JSP was something like this:
Code:
 	<t:field id="g_3" actionListener="#{d.VorgangsEditorUI.vorgaenge.textSearcher.onNext}" ... popupmenu="caseSensitivity" text="#{d.VorgangsEditorUI.vorgaenge.textSearcher.text}" ... />
 	...
 	<t:popupmenu id="caseSensitivity" >
 	<t:menuitem id="g_53" actionListener="#{d.VorgangsEditorUI.searchCaseSensitiveOn}" command="CaseSensitivityOn" rendered="#{d.VorgangsEditorUI.searchCaseInsensitive}" text="#{rr.editortexte['sorting_casesensitive']}" />
 	<t:menuitem id="g_54" actionListener="#{d.VorgangsEditorUI.searchCaseSensitiveOff}" command="noCaseSensitivity" rendered="#{d.VorgangsEditorUI.searchCaseSensititve}" text="#{rr.editortexte['sorting_caseinsensitive']}" />
 	</t:popupmenu>


My problem is now, that I would like to extract the context menu into my searchAndChooseColumns.jsp like this:
Code:
 	<t:field id="g_3" actionListener="#{PATHTOGRIDBINDING.textSearcher.onNext}" ... popupmenu="PATHTOUI-caseSensitivity" text="#{PATHTOGRIDBINDING.textSearcher.text}" ... />
 	...
 	<t:popupmenu id="PATHTOUI-caseSensitivity" >
 	<t:menuitem id="g_53" actionListener="#{PATHTOUI.searchCaseSensitiveOn}" command="CaseSensitivityOn" rendered="#{PATHTOUI.searchCaseInsensitive}" text="#{rr.editortexte['sorting_casesensitive']}" />
 	<t:menuitem id="g_54" actionListener="#{PATHTOUI.searchCaseSensitiveOff}" command="noCaseSensitivity" rendered="#{PATHTOUI.searchCaseSensititve}" text="#{rr.editortexte['sorting_caseinsensitive']}" />
 	</t:popupmenu>


My rowinclude would then look like this:
Code:
 	<t:rowinclude id="g_13" contentreplace="PATHTOUI:d.VorgangsEditorUI;PATHTOGRIDBINDING:d.VorgangsEditorUI.vorgaenge" page="/util/searchAndChooseColumns.jsp" />


Of course, this cannot work, since the Dev Guide says about Popup Menus:

Popup menus are defined on top level of a page. In the example there are three popup menus defined, each getting an explicit id: "POPUPMENU1", "POPUPMENU2" and "POPUPMENU3".
 


Even worse defining the Popup Menu with the ID d.VorgangsEditorUI-caseSensitivity and then referencing it in the searchAndChooseColumns.jsp via popupmenu="PATHTOUI-caseSensitivity" wont work.

Is there any way to get a dynamic popupmenu running within a jsp which is used in several places via rowinclude?

Thanks,

Björn
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5555
Offline

Hi,

"in general": there are two ways to react on Popup Menus:

1. using the actionListener of the POPUPMENU - then the problem is/may be that you do not know the component, which currently was hit.

2. using the actionListener of the component having the POPUPMENU - in your case the FIELD - then you exactly know the reference

2. is always a better option for situations, in which the "where was it clicked" is relevant...

Now looking on your example: why should this not work (you say "of course this cannot work"? The way you create the ID (via contentreplace) ensures via PATHOUI that each POPUPMENU has a unique ID, and this ID is properly referenced from the FIELD. So, from my perspective it should work.

Regards, Björn

And last, again "in general": for modularization of screens: please check the PAGEBEAN concept!!! It's fascinating, how you use CONTENTREPLACE (and this really is not trivial!) but using PageBeans this is completely done internally and is much easier to use, from my perspective...


Björn Müller, CaptainCasa GmbH
bthalheim

Power User

Joined: 05/04/2012 11:45:24
Messages: 72
Offline

Hi,

to make my point clearer, I wrote down a dummy project to illustrate my problem.
Please have a special look at the searchbar.jsp. It is used in two different JSPs. Searching works well in both (so rowinclude and contentreplace work fine), but the popupmenu to switch case-sensitivity switches case-sensitivity always in one of the pages/grids, but not both as it should do.

Can you tell why this is?

Tanks,

Björn
 Filename jsp.zip [Disk] Download
 Description folder has to be placed below webcontent.
 Filesize 6 Kbytes
 Downloaded:  415 time(s)

 Filename src.zip [Disk] Download
 Description Java-Sources: src.
 Filesize 9 Kbytes
 Downloaded:  417 time(s)

CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5555
Offline

Hi,


...oooh, there are quite a lot of issues in your example, so I prefer to show how to do it... (sorry):

FIRST, the re-usable page bean:

Code:
 <f:view>
 	<h:form>
 		<f:subview id="jsp_correct_correctsearchbarg_sv">
 			<t:row id="g_1">
 				<t:pane id="g_2">
 					<t:row id="g_3">
 						<t:label id="g_4" text="Search" width="100" />
 						<t:field id="g_5"
 							actionListener="#{d.CorrectSearchBarUI.onSearchFieldAction}"
 							popupmenu="SEARCHPOPUP"
 							text="#{d.CorrectSearchBarUI.searchField}" width="200" />
 					</t:row>
 				</t:pane>
 			</t:row>
 			<t:popupmenu id="SEARCHPOPUP">
 				<t:menuitem id="g_6" command="CLEAR" text="Clear" />
 				<t:menuitem id="g_7" command="DOUBLE" text="Double" />
 			</t:popupmenu>
 			<t:pageaddons id="g_pa" />
 		</f:subview>
 	</h:form>
 </f:view>
 
 
 package managedbeans;
 
 import java.io.Serializable;
 import org.eclnt.editor.annotations.CCGenClass;
 import org.eclnt.jsfserver.elements.events.BaseActionEventPopupMenuItem;
 import org.eclnt.jsfserver.pagebean.PageBean;
 
 import javax.faces.event.ActionEvent;
 
 @CCGenClass (expressionBase="#{d.CorrectSearchBarUI}")
 
 public class CorrectSearchBarUI
     extends PageBean 
     implements Serializable
 {
     String m_searchField = "test";
 
     public CorrectSearchBarUI()
     {
     }
 
     public String getPageName() { return "/jsp/correct/correctsearchbar.jsp"; }
     public String getRootExpressionUsedInPage() { return "#{d.CorrectSearchBarUI}"; }
 
     // ------------------------------------------------------------------------
     
     public String getSearchField() { return m_searchField; }
     public void setSearchField(String value) { this.m_searchField = value; }
 
     public void onSearchFieldAction(ActionEvent event) 
     {
         if (event instanceof BaseActionEventPopupMenuItem)
         {
             BaseActionEventPopupMenuItem e = (BaseActionEventPopupMenuItem)event;
             if ("DOUBLE".equals(e.getCommand()))
             {
                 m_searchField += m_searchField;
             }
             else if ("CLEAR".equals(e.getCommand()))
             {
                 m_searchField = "";
             }
         }
     }
 }
 



AND NOW THE EXAMPLE with 2 instances:

Code:
 <f:view>
 	<h:form>
 		<f:subview id="jsp_correct_testg_sv">
 			<t:rowtitlebar id="g_1" />
 			<t:rowheader id="g_2" />
 			<t:rowbodypane id="g_3" rowdistance="5">
 				<t:rowpagebeaninclude id="g_4" pagebeanbinding="#{d.TestUI.sb1}" />
 				<t:rowpagebeaninclude id="g_5" pagebeanbinding="#{d.TestUI.sb2}" />
 			</t:rowbodypane>
 			<t:rowstatusbar id="g_6" />
 			<t:pageaddons id="g_pa" />
 		</f:subview>
 	</h:form>
 </f:view>
 
 
 
 package managedbeans;
 
 import java.io.Serializable;
 import org.eclnt.editor.annotations.CCGenClass;
 import org.eclnt.workplace.IWorkpageDispatcher;
 import org.eclnt.workplace.WorkpageDispatchedPageBean;
 
 import javax.faces.event.ActionEvent;
 
 @CCGenClass (expressionBase="#{d.TestUI}")
 
 public class TestUI
     extends WorkpageDispatchedPageBean 
     implements Serializable
 {
     CorrectSearchBarUI m_sb1 = new CorrectSearchBarUI();
     CorrectSearchBarUI m_sb2 = new CorrectSearchBarUI();
     
     public TestUI(IWorkpageDispatcher workpageDispatcher)
     {
         super(workpageDispatcher);        
     }
     
     public String getPageName() { return "/jsp/correct/test.jsp"; }
     public String getRootExpressionUsedInPage() { return "#{d.TestUI}"; }
 
     public CorrectSearchBarUI getSb1() { return m_sb1; }
     public CorrectSearchBarUI getSb2() { return m_sb2; }
     
 }
 




You see: in the re-usable page the actionListener is not plugged to the menu item but is plugged to the FIELD itself. This is the main issue from my perspective...!

And: the page bean is included twice via ROWPAGEBEANINCLUDE.

Reagrds,
Björn
 Filename zzcell2.zip [Disk] Download
 Description
 Filesize 15 Kbytes
 Downloaded:  413 time(s)


Björn Müller, CaptainCasa GmbH
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team