I want to add Tab and tabPanel to specific page xxx.zul!
parentTabs = (Tabs) new Path("//root/lay/tabs").getComponent();
where root is ID for Page , lay is ID for BorderLayout and tabs is ID for Tabs Tag.
Note : Id don't have window tag in target page!
thanks
Oke you can add a zul page to an other zul page by doing this :
<?component name="details" macro-uri="../folder/myzul.zul" inline="true"?>
<window>
...
<details/>
...
</window>
the code to handle that part is in your MVVM of the main zul page. So if you do in the details an #bind(vm.list) you will need to have an getList and setList in your viewmodel.
Mine trick is that I write interfaces for those specific pages (you can implement multiple interfaces so multiple components are possible that way).
By that I know I will not forget any getter or setter that I need and they will remember me also on what variables I need to declare.
The visibility you can do with :
<tab label="tab2" visible=#load(vm.tab2Visible)/>
Hope this can help you.
Related
I have a jsp page which iterates a list of users. Each user has his own display picture. I want to display these display pictures.
The problem is that when the page is loaded all the images are the same instead of a different image for each user.
The image tag in the iterator is this :
<img src="<s:url action="getUserImage">
<s:param name="user">
<s:property value="userId"/>
</s:param>
</s:url>"/>
and the action looks like this
this.inputStream = ByteArrayInputStream(userService.getUserById(Integer.parseInt(user)).getDisplayPicture());
While debugging I discovered that when executing the action for each image, the 'user' property is always the same.
The funny thing is that when I inspect the imgs elemnt on a browser, the src parameters are all correct (meaning each of them has its own different values).
I'm using spring framework, auto wiring action classes ..
struts.objectFactory value ="spring"
Shouldn't userService.getUserById(Integer.parseInt(user) be userService.getUserById(Integer.parseInt(userId) ?
#Component
#Scope("prototype")
did the trick !
action class was reusing the same id for each request
I've a tomcat application with jsf 1.1
Case:
My application has a jsp (let name it /create.jsp) that contains a form to create a Business Object (imagine type person). One of the attributes of this Business Object is a relation to itself (the BO person, has an attribute father, that is also of type person). For this porpose, in the jsp, I have a selectable, and a button. The button enables to create new Business Object (in this case, a person). Therefore, the jsp show in the popup is the same that the one shown in the main window
Problem:
I'm facing wrong behaviours in the main window.
Cause:
I've studied the case, and the reason of the problem is the ids of the views stored in the server. When the users requires a new page, the server creates a view (ViewRoot) and stores it at the session. The jsp path is used as the id of the View. When the user submits a form, it will rehuse the same view stored in the session.
The problem in my case is that the popup ViewRoot, and the main window ViewRoot share the same id. So when the main window is shown, its viewRoot will be stored (let say id /create.jsp), but, when the popup is shown, its viewRoot will overwrite the main one in session. After closing the popup, the user will try to submit the main page, but in the server, there is no such a ViewRoot.
Possible Solution:
I've been thinking on changing the ViewRoot id creation, but I thing that this is not feasible (at least if I don't modify the jsf library).
---OLD TEXT---
I have a jsp with a form (let name it /create.jsp), that opens a popup window. This popup will also use /create.jsp .
Due to that JSF view-id, is fomed by the jsp path, both pages will share same id. So when the popup is displayed, the view stored in the session for the main page is overwritten by the new one. Because of this, the application is not working properly.
Is there any way to change the ids of the views? anyone has any solution?
Thanks
You probably want to look into using a subview . You can assign a name-space within this that will essentially create a new namespace within the page. In facelets that would be:
<f:view id="main">
<ui:include "myOtherJsp.jsp" /> <!-- This containing a subview -->
</f:view>
Alternatively I think you may just need to separate the page into multiple views:
<f:view id="mainpage">
<p>Page content</p>
</f:view>
<f:view id="popup">
<p>My Popup</p>
</f:view>
I don't know the specifics of your application, but I can't see a situation where there's a reason to not have multiple views/forms. I'm guessing separation will fix your problem. You can use some elements of JSF outside the view ( so there's no reason to use a single view per page unless you're forced.
Caveat: I'm a JSF2 developer for the most part and I haven't done a JSF1.1 app in a long time.
My final solution is the following:
Create a jsp name popup_create.jsp, that only contains an inlcude to the create.jsp
Duplicate create.jsp entry in facesconfig with popup_create.jsp
Create a ViewHandler (add it in config) with an extension of ViewHandlerImpl, where createView & restoreView methods are ovewritten, so that the viewId, in case that is create.jsp, and we are in a popup, it will modify the viewId to poup_create.jsp.
As I think this may be done in a more elegant way, it is the only way I've found.
I have a an a4j:outputPanel that is rendered based on some boolean condition:
<a4j:outputPanel id="someDisplayRegion" rendered="#{doc.ready && someClass.someBooleanMethod}">
// bunch of stuff //
</a4j:outputPanel>
Then on the same .xhtml page, I have a drop-down menu and selecting one of its options should reRender the above region:
<rich:dropDownMenu>
<f:facet name="label">
<a4j:commandLink styleClass="btn-pulldown">
<span><h:outputText value="Export"></h:outputText></span>
<span class="opener"></span>
</a4j:commandLink>
</f:facet>
<rich:menuItem submitMode="none">
<s:link
rendered="#{someOtherBooleanMethod}"
value="#exportDoc"
action="#{runSomething.exportDoc()}"
reRender="someDisplayRegion"
target="downloadfile"
><s:conversationId /></s:link>
</rich:menuItem>
</rich:dropDownMenu>
However, when I click on the menu item from the drop-down menu, it does not go into someClass.someBooleanMethod and thus, does not re-render someDisplayRegion. Am I doing something wrong?
Consider this point of the RichFaces documentation:
As with most Ajax frameworks, you should not attempt to append or
delete elements on a page using RichFaces Ajax, but should instead
replace them. As such, elements that are rendered conditionally should
not be targeted in the render attributes for Ajax controls. For
successful updates, an element with the same identifier as in the
response must exist on the page. If it is necessary to append code to
a page, include a placeholder for it (an empty element).
So add a wrapper around your outputPanel and target the wrapper in the reRender attribute.
<a4j:outputPanel id="wrapper">
<a4j:outputPanel id="someDisplayRegion" rendered="#{doc.ready && someClass.someBooleanMethod}">
// bunch of stuff //
</a4j:outputPanel>
</a4j:outputPanel>
<s:link reRender="wrapper" [...] />
s:link doesn't have reRender attribute, it's only available on RichFaces components.
rich:menuItem and s:link aren't the best of friends. (especially not in earlier version of RichFaces).
Is there a specific reason why you want to use s:link here ?
Putting the action and the reRender on the menuItem itself should work fine.
I don't understand why you think clicking on the menu item should go into someClass.someBooleanMethod and not into runSomething.exportDoc(). At what point are doc.ready and someClass.someBooleanMethod being set to true? You might put a debugging statement in your code that verifies these are being set to true. If they are set to true and your a4j:outputPanel is still not rendering then you have a problem. I use the s:link as you do here and it works, but I remember having to fiddle with it. Make sure the action fired in the s:link returns a String. "actions" have to return strings that can be used for navigation though in my case the page navigates to itself (like yours).
I have an include page which is a navigation menu. When i click on those menu i want to refresh the content area of layout with a certain page. How can i pass the page name into a JSF page using include tag
I dont want to switch to facelets and also i tried using $ and calling the backing bean method. It works but no css or richfaces components renders properly.
Thanks
Raj
I am not sure about the RichFaces part, but you can just use EL in <jsp:include> as well.
<jsp:include page="/WEB-INF/#{bean.pagename}.jsp" />
If bean.getPagename() returns for example home, then this will include /WEB-INF/home.jsp. You also need to ensure that the JSF/HTML contents of home.jsp is wrapped by a <f:subview> with an unique ID.
As to the CSS trouble, just ensure that the generated HTML validates and that the CSS imports in the <link> tags are all valid.
I may be missing a couple of points, but I've hacked together a jsf/richfaces app and want to be able to do the simplest ajax-based nav:
main page contains ref to my backing bean's menu
<h:form>
<rich:dropDownMenu binding="#{PrismBacking.nodeMenu}" />
</h:form>
this refers to the code for the backing bean methods
this is my main page ajax panel
<rich:panel id="content">
<a4j:include viewId="#{PrismBacking.viewId}" />
</rich:panel>
i can't work out how to get the backing bean to use the selected item from the rich:dropDownMenu to update that which is returned by getViewId.
i guess:
1) i need to ensure the menu items in the getNodeMenu method have the right payload so setViewId is called with the correct String and my rich:panel id="content" is reRendered.
any pointers as to how to do this would be greatly appreciated.
mark
You are not setting the reRender attribute anywhere in your code (in the menu items) so the panel is not going to be updated after you select an item from the dropdown.
You also have to set the ajaxSubmit attribute en each menuItem to true in order to execute an ajax request. Also check that your listener is executed.
Take a look at the example http://livedemo.exadel.com/richfaces-demo/richfaces/dropDownMenu.jsf?c=dropDownMenu . You can download the code if you want from the richfaces site.
Using binding should be avoided if possible. Take a look at the RichFaces demo - there are source codes for each example, and see how it is achieved.
(This doesn't answer your question, and for better :) )