I have a package with a taglib that consist of a few custom made component.
There is a component uses icefaces "Panel Popup", which I created to do multiple-value look-up and to be used across multiple project.
I have been trying to use <ui:include> to attach it to other popup bean and rendered when required.
But it just won't work. I even uses
<namespace:Component> <namespace:Component>, the page runs properly but just won't render
the component when I click a button to make it visible.
The component works properly when I use <ui:include src="url link"/>, but I do not want the component to exist in every project, I want to share it using a package.
May I know if there is other solution?
Thanks in advance
Caveman programmer!
Related
I would like to know how to check if a component (ex. p:inputText, p:password, and etc.) is disabled in PrimeFaces through Java? Because I plan on processing my form dynamically depending on the state (disabled/enabled) of the component. I know about PartialSubmit in PrimeFaces but to use it, you have to type the ID of the component you only want to process, which I don't want since I'm hardcoding the components I will process. Thank you.
I'm using PrimeFaces-6.2.RC2.jar and JSF 2.2.16 Mojarra.
I think i have a fundamental problem with understanding Wire components if some one could explain why they work with a Composer and the doAfterCompose()-Method and why the wiring dosen't work (Component -> NULL) in a #command-Method (like onClick from a button).
I can't post the whole code so I'am just pasting parts of a working zul and a working Java Class
I used MVVM to access some values from ZUL-Components. The java class used for this also generates some components dynamically with data from a database (in doAfterCompose()-Method).
Szenario: the gui shows up and via doAfterCompose() several components are created dynamically (Row Component + Checkbox in the Row Component) with the Wire Component orgTypeRows (Type Rows). That works fine.
But to acces the results you click on the search button which has the onClick event "startSearch" which calls the java method startSearch(). In this method I want to access the generated components (Type Checkbox) and verifiy which boxes have been checked but when i try to access the wire component here the Rows Component is NULL
Here is the ZUL-Code search.zul and the Java-Code search.java
Is this impossible like that? Should i just use a listener for the button in doAfterCompose() instead of the #command but how can I access the viewmodel in doAfterCompose() there all values of the viewmodel are NULL?
I think you have a fundamental problem with MVC and MVVM.
Let's start with the zul you showed.
I can't find any apply attribute in the zul so the controller or viewmodel must be applied in another zul, so I don't know what you are using, MVC or MVVM.
The loading of the properties are the MVVM way.
Let's go now to the java class.
You are mixing 2 completly different things.
First of all extending the GenericForwardComposer is an MVC way.
It's even an old one because the SelectorComposer is the newest MVC controller where you can annotate the wiring what must be done.
#Init, #Command => MVVM
#doAfterCompose, wiring => MVC
Now you say that the #Command method isn't working. Do you mean not triggering?
Don't forget that the MVVM way need's a binder.
Initialisation of a viewmodel :
apply="org.zkoss.bind.BindComposer" viewModel="#id('vm') #init('yourPackage.YourClass')"
Initialisation of an MVC controller :
apply="yourPackage.YourClass"
See the difference?
Please, read the documentation about MVC and MVVM on zk website.
Refactor then your whole thing, and if you still have problems come back with a better question where we can help you with.
I would like to know which are the different available approaches to add, modify and delete UI components before a page loaded.
A practical example that I should handle is the following:
In my ADF Fusion Web Application (developed with JDev12.1.3) there are the pages login.jspx and main.jspx: if the user logs in correctly navigation to main.jspx happens.
In main.jspx there is an empty menu bar that at runtime I would like to fill with menus and menu items when the page loads, in function of the logged in user.
In the same page, in function of the logged in user, I also would like to add at runtime some UI components (output texts, buttons, ...) whith the chance to set their properties.
Could you kindly advice me which approaches I can follow to accomplish these duties?
Thanks,
Federico
Why not using the rendered attribute? Based on the condition the components will be rendered or not.
Personally the two approaches i've used on my works where:
1. Using the beforePhaseListener on the f:view component. Example: Before Phase on JSF page. But it might cause you some problems when taking account of adf lifecycle, especially if you have integrated parts (or even some simple jQuery components...).
2. And i think this would just do fine in your case, use a f:event component of type "preRenderComponent". Example: How to use prerendercomponent. I suggest this second option
Note: It's true that these aren't ADF Faces components, but since it's built on top of JSF, they work as they should. I can assure you they do work on 11g and don't expect any problems on 12c.
I see two approaches. Use addChild() and related methods to physically add/remove menu items, or have the menu pre-built and use the visible property to show hide items.
As far as making this happen in custom code, you can use a Backing Bean (Managed Bean) that contains the code to determine what items to add/remove or make visible based on whatever criteria you choose. To call this code, you can 1) use the Invoke action in the rebinding layer - have it call the desired backing bean method - make sure to drag the Invoke action the TOP of the executables list. This is the older, less preferred method. The newer, more preferred method is to add the backing bean method to the Task flow and have it navigate to the deserted page. This method can be part of the navigation form another page. Ex: After successful Login, navigate to your method an chav sit navigate to the Main page. The method will execute before the page loads and will set values to have the items added or visible or not.
RichSelectOneChoice choiceList;
List child = choiceList.getChildren();
child.clear();
for (int i = 0; i < child.size(); i++){
child.remove(i);
}
if ("1..1".equalsIgnoreCase(ccCode)){
UISelectItem addChild = new UISelectItem();
addChild.setItemLabel("1..1");
addChild.setItemValue("1..1");
child.add(addChild);
} else if ("0..1".equalsIgnoreCase(ccCode)){
UISelectItem addChild1 = new UISelectItem();
addChild1.setItemLabel("0..1");
addChild1.setItemValue("0..1");
child.add(addChild1);
UISelectItem addChild2 = new UISelectItem();
addChild2.setItemLabel("1..1");
addChild2.setItemValue("1..1");
child.add(addChild2);
}
Have you posted this question to he ADF forum, here?
I need to create a user interface where the content changes every time the user moves to a new page. However, the header and footer remains the same.
But, within the content, there is sometimes a left pane visible on some of the pages.
I'm not sure how can this be achieved since I'm new to using JSF.
Can someone please suggest a way?
Thanks!
You can achieve this by creating 2 different layouts and using for the correct layout
one with left rail
another without left rail
You need to look at JSF template with Facelets
Here are some links that you can refer
Link 1
Link 2
For the 'puzzly' composition of pages you need to use templating. Great overview can be found in the answer to How to include another XHTML in XHTML using JSF 2.0 Facelets?. The layout itself is HTML/CSS-related, so you need to check that out first.
If you want to produce one part of a template conditionally, there are two possibilities: to do that from a master template, or to do it from a template client. Of course, you could create many templates, as others recommend, but this is counterproductive and hard to maintain in my opinion.
If you want to render a part of template conditionally, you can include rendered="#{view.viewId = '...'}" attribute to JSF components in master template.
Alternatively, if you want to 'overwrite' the default part of a template, that for example has a left panel, just define the target area as an empty one in a template client like <ui:define name="left" />.
I have been writing some basic code for an application I am designing. I have learned the basics and gotten some simple database connection working with RPC calls etc. What I need to do now and am completely lost (as I am traditionally a c# developer with windows forms).
In c# if I wanted a new form I would just create it, and then call the show method.
How does one create multiple pages in GWT, and switch between them?
Thanks in advance,
Chris
The simplest way would be to
Make a new java class (GwtHome.java, GwtHelp.java etc)
Extend these classes by using the Composite class
Make the equivalent of a Master Page and add it to the rootPanel as a class with the appropriate headers, menu, footer and Content Placeholder (Could be any of the AbsolutePanel, VerticalPanel, HorizontalPanel objects provided by the GWT Framework)
By clicking on the menu clear the Placeholder and add the appropriate object of GwtHome, GwtHelp etc.
After getting aquanted with the above procedure, you might want to break up the code in many files using a design pattern as suggested by Andrei.
Simply clear the root panel (RootPanel.get().clear()) and add the widget for your new "page", the same way you added your first one.
If you're using LayoutPanels, do RootLayoutPanel.get().clear() instead.
Look at Activities and Places design pattern: https://developers.google.com/web-toolkit/doc/latest/DevGuideMvpActivitiesAndPlaces
I highly recommend it for a multipage GWT app. It explains pretty well how you create different "views", that are driven by their "activities", and tied to specific "places" (pages) that users can navigate.
Typically you use a LayoutPanel as your "page" container that occupies the entire available browser window. You split this LayoutPanel into 2-3 layers (zones), like top menu, side menu, main area. Each area contains one widget, usually a ScrollPanel, FlowPanel, or HtmlPanel. Then you use different widgets or HTML inside each of these widgets to display whatever you need. You may also create your own composite widgets that you can reuse in different pages.