RenderParam of type public is not storing value - portal

I have the following link setup in a WCM component.
When a user clicks on the link, I'm trying to initialize a public render parameter to that the value stored inside citySelected is available to other components + multiple portlets.
[Plugin:ifNotEmpty value="[Plugin:RenderParam key='citySelected' type='public']"]
Not empty.
[/Plugin:ifNotEmpty]
<a href="[Plugin:RenderURL
pr1.mode="set"
pr1.value="citySelected"
pr1.key="citySelected"
pr1.type="public"
title="">
[AttributeResource attributeName="name" separator=","]
</a>
The problem is the value is not stored, but it is stored if I switch to a private parameter.
Currently when link is clicked the portlet is refreshed and tries to display the value, but nothing is ever displayed?

Need to pass a qualified name when setting a public render param e.g ..
[Plugin:RenderURL copyCurrentParams="true" uri="nm:oid:pageid"
pr2.key="{http://ibm.com}prp1" pr2.value="pv1"
pr2.type="public" pr2.mode="add"]
http://www-01.ibm.com/support/knowledgecenter/SSHRKX_8.5.0/mp/social/plrf_rendr_plugin_render_url.dita

Related

Automatically provide data to Express partial views

I'm writing an Express 4 app, and am currently using twig.js as the view engine since I find it comfortable, though I could be persuaded to change this engine.
I've done a lot of development with PHP/Laravel and have gotten used to what in that camp they call view composers. Using these I can write a composer for a particular view, whether it's a main page view, a layout which other views extend, or a partial other views include. The composer does any necessary logic to prepare whatever data the view needs, and then attaches it to the view's context so it's available during rendering.
For example, I might have a partial which shows the current user status, so if they're logged out it'll maybe have just a log in button, and if they're logged in it'll have their icon, username, and a menu to let them log out etc. The corresponding composer would check to see if a user is logged in, and if so attach the relevant data about the user to the view's context. It then doesn't matter which page includes this partial; the data will always be available without me having to remember to add that specific data to the context passed to the page's main view.
Is there some equivalent in Express? Or does it depend on the template engine I'm using?
Currently, views that are rendered using res.render() need to have their data passed in on every res.render(). If the view uses a partial template that requires certain data points, the view that uses that template will need to have that value passed in through res.render(). So in short, you always need to pass the data in regardless if the data point is required by a partial template that might be shared. When using view engines, nothing is automatically provided to the view.
Are you asking if it's possible to have some view A, that includes partial P_A and be able to pass some data to the partial that's not dependent on routing, i.e wherever you are on the site / app your partial has data bound to it (totally independent of both the route / url and view ) which you could use for your logged in status ?
if so then create your partial, let's use a navigation / menu partial:
please note that this example uses ejs for templating
<nav>
<ul>
<!-- pass the data upon call / include-->
<% for(var i = 0, len=navigation.length;i < len;i++) {%>
<li><%=navigation[i].Text%></li>
<%}%>
</ul>
</nav>
Call / Include your patial on a view
view.ejs
<%- include('nav', { navigation : [{Text : 'Items' ,href : '/' },{Text : 'People' ,href : '/names' }] } )%>
To my knowledge there is nothing like that in expressjs.

ADF Refresh page jsf with page fragments jsff after set session variable

I have a template which includes a button that let you select a profile, you push the button and appear the available profiles, choose one and push accept. After that I set a variable session successfully.
I have a "First" jsf page with two jsff page fragments from a View Link. The view link is composed by a headerView and detailView. The headerView had a bind variable. What I need is that parameter (bindVariableParameter) can be set by the session variable of the template.
This is what I get:
I am in a home page (separate Application Module), I push the template button before I load de "First" jsf page and after that I go to the "First" jsf page the information is loaded successfully. What I do in the Application Module is something like that:
protected void prepareSession(Session session) {
Map sessionScope = ADFContext.getCurrent().getSessionScope();
String company = (String)sessionScope.get("compId");
System.out.println("Default Comapny in BC is: " + company);
super.prepareSession(session);
this.getSession().getUserData().put("Company", company);
System.out.println("After setting value in userData map of BC");
}
And in the bind variable expression of the headerView I use:
adf.userSession.userData.Company
It works great!!!! But!!!!
When I press the button again and I choose another profile, the info is not updated. Neither in the headerView neither in the detailView.
Also, when I go to the "First" jsf page (without previously push the template button), I got no info, which is right, because I don't have any session variable. After that I push the template button and select the profile, but the page is not refreshed.
I tried several ways to to this but I'm lost.
Could you help me?
Regards.
You have two options for this:
Option one: tune your AM as follows:
jbo.doconnectionpooling=true
jbo.txn.disconnect_level = 1
This will ensure prepareSession() method is being called before each operation. This happens to be a best practice in ADF productions systems, increasing scalability (see here )
Option two: Better than using prepareSession(), you can pass the Http Session data to ADF BC through a custom DataControlFactory.
You can find an example here: http://andrejusb.blogspot.co.uk/2012/05/solution-for-sharing-global-user-data.html

JSF Trouble with beans (scope)

So I was testing my JSF application and suddenly I can't pull the value I stored in the bean anymore. I switched from Request scope to Session scope and I was able to pull a value, but it seems to be the value of the last page I clicked.
File structure goes something like this:
About.xhtml sets a page number stored on the Bean and then calls Layout.xhtml which calls Bean.Method() to get Content_About.xhtml to load some text to the page depending on the page number declared in the About.xhtml file.
To my understanding the Request scope should work as long as I don't need to access the stored information past the page loading, but it is acting as if the page number hasn't been set.
With a Session scope declared, it loads the text, but it seems as if it is building the page, then changing the stored value in the bean. It requires that I click on the page I want twice to get the correct information on a page.
Any help appreciated.
Further investigation: I am able to do the following, but it shows the correct page number before and after the method call to load the content.
Page Number: #{MainBean.getPage()}
<h:form>
<ui:include src="#{MainBean.Content()}"></ui:include>
</h:form>
Page Number: #{MainBean.getPage()}
Accepting that the ui is built first, using the default value of the stored variable, I proceeded to set the value in the ui declaration when layout is called.
I had something like:
#{MainBean.setLevel(0)}
#{MainBean.setPage(1)}
<ui:include src="Layout.xhtml"></ui:include>
and changed it to:
<ui:include src="#{MainBean.setLayout(0,1)}"></ui:include>
public String setLayout(int lvl, int pg)
{
setLevel(lvl);
setPage(pg);
return GetPath()+"Layout.xhtml";
}
This allows the bean's variable to be set during the construction of the ui and carry forward through the rest of the request.

Access a component of a custom control

I have a custom Control which I'll call ccViewTemplate with this code in it:
<xp:repeat id="repeatData" rows="30"
value="#{viewEntry}" var="veData"
first="#{javascript:return (sessionScope.ssFirst != null)?sessionScope.ssFirst:0;}">
<xp:panel id="panelSelect">
<xp:callback facetName="viewBodyFacet" id="callback1"></xp:callback>
</xp:panel><!-- panelSelect -->
</xp:repeat>
the database view (viewEntry) is also defined in ccViewTemplate and defined based on several custom properties. ccViewTemplate is then added to another custom Control called ccFinalView. Where the custom properties are entered, and the content of the display is entered into viewBodyFacet. I have access to veData and a everything works great to this point. In the viewBodyFacet I have a link that does a redirect to open the document which also works fine. However, in the link I want to get the repeatData Property First and store it so that it returns to the correct page of the repeat. I use this code:
sessionScope.put('ssFirst',getComponent("repeatData").first);
However, the code can not find the getComponent("repeatData") because it is inside ccViewTemplate and not accessible. Is there a way to get the component repeatData from the ccViewTemplate while in ccFinalView which contains ccViewTemplate.
I have done getComponent("ccViewTemplate") and I have the handle to the custom Control, but
getComponent("ccViewTemplate").getComponent("RepeatData").first fails. So is there a way to pull a value from a component 'inside' a custom control from 'outside' the custome control?
looked a little further and found this:
var rtn = getComponent("ccViewTemplate").getPropertyMap().getProperty("repeatData");
It does not generate an error but returns nothing, if I add
var rtn = getComponent("ccViewTemplate").getPropertyMap().getProperty("repeatData").first;
I get an error getComponent() is null
Hope this makes sense.
From what I understand, this is a perfect job for a java bean. The bean can even keep a default value.
public class Controller{
public String value;
public Controller(){
value = "default_value";
}
public String getValue(){return value;}
public void setValue(String value){this.value=value}
}
In this fashion, the value will be available as soon as the object is created. pressing the button then sets the value with javascript,
ControllerBean.setValue("thisValue");
and you can read the value
ControllerBean.getValue();
This question shows how to configure the bean: How to set up a managed bean to work with Notes document
By setting this to, say the viewScope, you can then access the value anywhere you need regardless of whether or not it is in a custom control or main page. I highly recommend this approach. It just means possibly rethinking your custom control structure.
EDIT
Extra ideas include having an enum that maintains the views,
public enum Views{
VIEW_1("viewAlias", "urlParam")
private String vwAlias;
private String urlParam;
private Views(String alias, String param){
vwAlias = alias;
urlParam = param;
}
// public getters
}
And then in your controller you can get the view string:
1. By seeing if a view param is included in the URL
2. If a cookie value is set
3. Take the hard coded default
Clicking the change view action then sets the cookie value and changes the view parameter and redirects.
This is all extra ideas, but it is how I build my view controllers. I will be doing a tutorial on that soon.

Cannot use attribute forms in page template?

I am using JDeveloper 11.1.2.3.0
I have to show a popup by clicking a link that is located in the page template. For this I created a popup within the pageTemplate then inserted a dialogBox and within the dialog box I dragged and dropped my VO from the DataControl panel and inserted it as an ADF form. The problem is that when I run and click the link (that contains the "ShowPopupBehavior") I am getting this error:
//C:/Oracle/Middleware/jdeveloper/jdev/system11.1.2.3.39.62.76.1/MyNew/ViewControllerWebApp.war/WEB-INF/templates/myTemplates.jsf #58,118 value="#{bindings.TypeName.inputValue}": Target Unreachable, 'TypeName' returned null
ADF_FACES-60097:For more information, please see the server's error log for an entry beginning with: ADF_FACES-60096:Server Exception during PPR, #2
This happens for every View that I can insert here. Is this comming because I am not allowed to insert ADF forms within the page template?
If so please give me a hint to achieve what I explained in the first sentence.
I just figured out the solution to this problem. Each page has its own bindings, so a page that uses the templates (or if want to use bindings from other pages) has to declare that page in the Executables section of the page Bindings. The new executable should have the ID of the page (of the template in this case) and the path of the page. Then the bindings of the template can be accessed as explained here:
public String cb1_action() {
BindingContext bctx = BindingContext.getCurrent();
DCBindingContainer bindings =
(DCBindingContainer)bctx.getCurrentBindingsEntry();
//access the page template Pagedef file reference in the
//Executable section of the consumer page's Pagedef file
DCBindingContainer templateBinding =
(DCBindingContainer)bindings.get("ptb1");
//get the MethodBinding
OperationBinding printMethod =
(OperationBinding)templateBinding .get("printThis");
//invoke the print method exposed on the template's PageDef file
printMethod.getParamsMap().put("message","Hello World");
printMethod.execute();
return null;
}
https://blogs.oracle.com/jdevotnharvest/entry/how_to_invoke_adf_bindings
ps: Pay attention not to bind the value of the template in your page ex: value="#{bindings.ptb1}" - it is a bit strange but in this case you will not get the page bindings and will get only the template ones.
The value property containing #{bindings.ptb1} should be removed from the pageTemplate tag but the ptb1 reference has to be in the pages PageDef file.

Resources