Component Scope
if you have a globally scoped component, it should not contain a property that holds a session-scoped component.
Can you give me an example?
When you inject a request scoped component to a global scoped component, then the global scoped component must be having a instance variable with setter/getter methods to get that injected value. So, if A is a global scoped component and you are going to inject B which is a lower scoped component, then in the class of component A, you will define an instance variable for B.
Now what will happen is that, if you inject B into A, then the object instance of B will not be destroyed even after the scope (request or session) is over, because the global component A has still got a reference to that.
But if you use the request.resolveName() to get a lower scoped component, you will be doing that anyway within a method and that becomes a local variable within that method and hence once the method execution is complete the component B will not have any pending references from the global component A.
I hope this explanation clears your doubt.
Similar Messages
-
Component scopes....
Guys,
Do we have any idea about,
Is that true, any scope component can call with in any other scope component?
Like...
Calling....
Session component from Global component
Request component from Global component
Global component from Session component
Request component from Session component
Session component from Request component
Global component from Request component
Could you please which is OK
Thank youIf you want, you can call droplet with global scope from formhandler technically.
But the purpose of droplet and formhandler are different. If you feel, the logic needed is inside droplet and want to call it, so that formhandler can access, then move the logic to manager class.
Droplets ( more like servlets and should be instantiated once and they are not meant for forms) and formhandlers(deal specifically with handling forms ) are just the ways to access/perform logic from front end jsp.
-karthik -
hi i have 2 classes one is my main and the other is the paint class with void paintcomponent() inside
how do i pass the x variable inside main class so i can use it inside the Map class
i know you can use scope e.g. Map map = new Map(x,y); but then i have to use a constructor with
its own repaint(); method inside but it does not work.
i was thinking of overloading a constructor aswell so inside one constructor is nothing and in the other with the (x, y) has
the repaint method inside but that doesn't work either.
main class
public class Main
public static void main(String[] args) {
MainFrame frame = new MainFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.setVisible(true);
class MainFrame extends JFrame
private int x;
private int y;
// map class with paint component
Map map = new Map(x,y);
public MainFrame(){
this.add(map);
}paint class
public class Map extends JPanel {
private int x;
private int y;
public Map(){}
public Map(int x, int y){
this.x = x;
this.y = y;
repaint();
@Override
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
}this does not work, any ideas?
Edited by: nicchick on Nov 25, 2008 1:00 AMum that wasnt exactly what i was looking for i have a better example
what im trying to do is pass/scope private varibles from the main class to the map class
but since you use repaint(); to call the paintcomponent override method theres no way to scope varibles like
x and y to panel?
this example shows what im trying to do with a mouselistener
main
public class Main
public static void main(String[] args) {
MainFrame frame = new MainFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.setVisible(true);
class MainFrame extends JFrame
private int x;
private int y;
// map class with paint component
Map map = new Map();
// handler
HandlerMotion handler = new HandlerMotion();
public MainFrame(){
this.add(map);
map.addMouseMotionListener(handler);
private class HandlerMotion implements MouseMotionListener
public void mouseDragged(MouseEvent e) {
public void mouseMoved(MouseEvent e) {
x = e.getX();
y = e.getY();
new Map(x,y);
repaint();
}map
public class Map extends JPanel {
private int x;
private int y;
public Map(){}
public Map(int x, int y)
this.x = x;
this.y = y;
System.out.println("this is map" + x);
System.out.println("this is map" + y);
repaint();
@Override
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.drawLine(0, 0, x, y);
System.out.println("this is panel" + x);
System.out.println("this is panel" + y);
} -
Looking for missing component for NISCOPE
I downloaded NISCOPE installation file(niscope.exe). When I tried to install it, I got an error message saying “Missing Component Scope-SFP 1.1f2”. Where can I find this component?
You can find the NI-SCOPE Soft Front panel on the National Instruments website at www.ni.com then follow the following links:
-Under Technical support "Downloads"
--"Drivers and Updates"
---"Current Software Versions"
----"Scope Soft Front Panel" -
Locking when using a component as an object in the application scope...
I have a component that I am building right now that hold
application settings that are stored in a database table. The
settings are maintained in a structure "variables.settings" within
the component and can only be accessed by get and set methods. I
use the following to create the instance of the object:
<cfset application.settings =
createObject("settings","component").init() />
Now when getting a setting I do not think locking is needed
as its just reading the value and I am not really concerned with a
race condition...
But when using the set method which will update the value of
the setting.... should I be locking that as technically the object
is in a shared variable scope? Or is it safe because its within the
cfc/object?
If locking is needed, would I need to lock when using the set
method? or can I just build the lock into the set method so that
its always there?To disagree with craigkaminsky, I think you only need to lock
if you are
concerned about race conditions and what could happen during
a 'dirty
read' and|or conflicting writes.
A lot of developers have an old impression of ColdFusion that
one *must*
lock all shared scope variable access to maintain a stable
application.
This dates from the ColdFusion 4.5 days where there where
bugs in
ColdFusion that could cause memory leaks and eventual
application
instability if one did not lock shared scope reads and
writes. This has
long been fixed, but the advice persists.
So now it is only a matter of your data and what would happen
if one
user read an old value while it was in the process of being
updated by
another user. Or could two users be updating the same value
at the same
time and cause conflict. If either of those two statements
are true,
then yes you should use locking as required by your
application.
But if they are both false and it does not matter that user A
might get
the old value microseconds before user B changes it. Or there
is no
concern with user A changing it once and user B changing it
again to
something different moments later without knowing the user A
has already
changed it. Then locking is probably unnecessary.
There can be a cost to over locking shared variable writes
and|or reads.
Every time one creates a lock, one is single threading some
portion of
ones code. Depending on how the locking is done, this single
threading
may only apply to individual users or it may apply to every
single user
on the entire server. Either way, too much of this in the
wrong places
can create a significant bottle necks in ones application if
too many
user requests start piling up waiting for their turn through
the locked
block of code. -
Error with the Scope parameter for component
Hi, I am using JSF2.0 in my web. In the home page (index.xhtml) i have an album gallery with session scope. However the gallery is available to all the users, what should be the scope for this component? After setting session scope, a session key is generated which is appended with the URL and because of this (perhaps) other links are not opening. i mean whenever i clicks on any link (about.xhtml), it displays nothing. Removing the bean from session scope makes everything fine except gallery (gallery doesn't rendered).
That version of the package has been built with apache 2.2.x. Be sure to use that version of apache too, as 2.0 won't work with that specific package.
-
JNDI lookup for request scope component,
Hi,
I have 2 web applications part of single ear file.
Where One application is ATG application having ATG pipeline defined in its web.xml
and 2nd one is a simple j2ee web application.
From 2nd application if I try to lookup a request scoped component by following code
String jndiName = "dynamo:/------compenent path------";
Context ctx = new javax.naming.InitialContext ();
Scheduler s = (Scheduler) ctx.lookup (jndiName);
it shows me following error.
** Error Fri Nov 16 11:04:20 CST 2012 1353085460117 / Invalid attempt to resolve component /atg/-------component path------/ in scope global. It is defined in scope request
Is there any way to resolve it ?
Edited by: Arvind Pal on Nov 16, 2012 2:00 PMIt seems the scheduler global component is resolving the request scope component internally.
For request scope components there should be DynamoHttpServletRequest object in context to resolve.
DynamoHttpServletRequest object is created as part of servlet pipeline.
As you request is not going thru servlet pipeline, there is no DynamoHttpServletRequest and hence the request scope components cannot be resolved.
So check in the scheduler why do you need to resolve the request scope component. Its not good practice to resolve them in schedulers.
Peace
Shaik -
Session scope for component tree subtree
I'm very new to JSF. Here is what I'm trying to do: I created a custom component, renderer, and tag. This custom action will always have children that are no custom, but whose rendering I must control (via encodeChildren, etc).
The problem I have is that the CSS style of these components will change after they are rendered (DHTML & AJAX). Some are hidden, color changes, size change, etc. When I go to another page with the same custom action included, of course it just renders a new version with all of the changes lost.
Now if this was a simple custom action with no children, I'd just create a managed bean with a value binding and there would be no problem. But what I am trying to do is save the ENTIRE subtree, ie. save the state of the custom component and all of its children also.
Now the messy way to do this would be to take my component, make it a managed bean, then include a value binding every time I use that custom action. The custom renderer would look to the bean for how to render the children, etc. The problem I have with this approach is that I basically have to include attributes in my component (used as a managed bean) that redundantly describe the children.
For example, my component:
class UISearch extends UIComponentBase {
private boolean showChild1;
private boolean child1Color;
etc..
OR a better option, to have:
private UIComponent child1;
public setShowChild1() {
child1.render = true;
....etc....
The problem I have with the above aproach is that every time a page is requested, the UIViewRoot tree will be build, a new Child1 will be instantiated, and then during the rendering of UISearch's encodeChildren I'll have to pretty much copy over attributes..
I wish there was a way that I could have a "managed component subtree" where UISearch and all of its children are instantiated once, held through session scope, and every time they are rendered, regardless of page, the existing, managed version is used.
This sounds so obvious, and I am almost positive there is a way to do this, I just don't know how.
Thank you!!!!!
PS:
I think I am on the wrong track. Basically all I want to do is have the UISearch and its children load the same normal way each time that they do now. I don't even care if the component tree is re-created, re-rendered, etc. But after this custom action is rendered, I call an AJAX loadConfig() type method that will return all of the style, innerHTML, src, etc. changes that must be updated.
So my question really is.. what is the best practice for storing and retriving this information? I'm using DWR, and I'd like the loadConfig() to return an object with all the config stuff nicely organized.. so if the returned object is "search" and I need to load the 'display' CSS style for some child, i can do:
child.style.display = search.history.clearHistoryLink.style.display;
Who knows. Any and all ideas are welcome!
Message was edited by:
rrc3243I found example (bookstore) where I got answer about using backing bean in session scope.
<!-- Backing Bean for bookshowcart.jsp -->
<managed-bean>
<managed-bean-name>showcart</managed-bean-name>
<managed-bean-class>backing.ShowCartBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<!-- Managed Bean -->
<managed-bean>
<description>
Create a shopping cart in session scope the first
time it is referenced.
</description>
<managed-bean-name>cart</managed-bean-name>
<managed-bean-class>cart.ShoppingCart</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
ShoppingCart class don't have data properties like lastName or orderId
Class have only somethings like this:
protected BookDetails book() {
BookDetails book =
(BookDetails) context()
.getExternalContext()
.getRequestMap()
.get("book");
return (book);
* <p>Return the <code>ShoppingCart</code> instance from the
* user session.</p>
protected ShoppingCart cart() {
FacesContext context = context();
ValueBinding vb =
context.getApplication()
.createValueBinding("#{cart}");
return ((ShoppingCart) vb.getValue(context));
* <p>Remove the item from the shopping cart.</p>
public String remove() {
BookDetails book = (BookDetails) item()
.getItem();
cart()
.remove(book.getBookId());
message(null, "ConfirmRemove", new Object[] { book.getTitle() });
return (null);
rule:
Don't use backing bean with data properties in session scope! -
Resolving session scoped component in global scope component.
Hi,
I am implementing batch process and i am need to resolve session scoped component in global scoped component.
In global scope component (one of the component referred by my scheduler which also in global scope as usual) and i need to resolve session scoped "/atg/epub/workflow/WorkflowView" component in my scheduler.
I tried all possibilities but nothing worked out. I do not have access to current request, because its batch process. following ways i tried,
1. getResolveName("/atg/epub/workflow/WorkflowView") method of GenericService which is extended by my global scope component -- This returns null.
2. Tried to get the current request on ServletUtils to use resolveName() method on request.
ServletUtlis.getCurrentRequest() - This returns null as expected.
Is there any way to resolve session scoped component in global scope component. Thanks in advance.
Edited by: 938890 on Jun 30, 2012 4:59 AMTry below :
If you want to resolve the name of a Nucleus component from Java code that is not itself a Nucleus service, you must first initialize Nucleus with this construct:
Nucleus.getGlobalNucleus().resolveName("target component")
where target component is the name of the component you are looking up. Note that this construct works only for components with global scope.
You can also resolve names of Nucleus components using the Java Naming and Directory Interface (JNDI). The following example shows how you can use JNDI to access the Scheduler component:
String jndiName = "dynamo:/atg/dynamo/service/Scheduler";
Context ctx = new javax.naming.InitialContext ();
Scheduler s = (Scheduler) ctx.lookup (jndiName);
reference - oracle ATG docs.
~ Praveer -
HI
how to find out scope of perticular component in atghow to find out scope of perticular component in atgAnother option is you can go upto ATG root directry and search ComponentName.properties file. Open file and check $scope=request/session/global. Default scope is global.
-RMishra -
Composite component attribute scope
I'm implementing a master-detail screen on bicycles are shown for the bicycle category selected. When the user selects a bicycle category in the selectOneMenu, the change request is handled using ajax and the new list of bicycles is displayed.
<cc:interface>
<cc:attribute name="categoryHolder" required="true">
<cc:attribute name="selectedCategory" />
</cc:attribute>
<cc:attribute name="onSelectCategory"
method-signature="void action()" required="false" />
<cc:attribute name="showAllOption" required="false"
default="#{false}" />
<cc:attribute name="onChangeRender" required="false" default="@form" />
<cc:attribute name="rendered" required="false" default="#{true}" />
</cc:interface>
<cc:implementation>
<h:selectOneMenu value="#{cc.attrs.categoryHolder.selectedCategory}"
rendered="#{cc.attrs.rendered}">
<f:selectItem itemLabel="All" itemValue="#{null}" noSelectionOption="#{true}" />
<f:selectItems
value="#{bicycleCategoryListUiComponent.bicycleCategories}"
var="bicycleCategory" itemLabel="#{bicycleCategory.name}"
itemValue="#{bicycleCategory}" />
<f:ajax event="change" render="#{onChangeRender}" execute="#{cc.attrs.categoryHolder.check()}" />
</h:selectOneMenu>
</cc:implementation>I call the component like this:
<component:bicycleCategoryList
categoryHolder="#{selectBicyclePageBean}" onChangeRender="@form" />However, when I select a category I get the following error message:
serverError: class javax.faces.component.UpdateModelException /resources/component/bicycleCategoryList.xhtml @32,35 value="#{cc.attrs.categoryHolder.selectedCategory}": java.lang.NullPointerException
It seems like #{cc.attrs.categoryHolder} has run out of scope and this isn't available anymore.Therefore I'm wondering how I can manipulate the scope of composite component attributes? JSF 2 has elegent scopes for managed beans, but I could not find anything about this topic. When there is some other solution, also please enlighten me.
Thanks in advance!Did you find a solution to your problem? I too am trying to do something similar but rather than have an onChangeRender attribute, I was trying to find a way to nest <f:ajax> inside the call to the custom component. Using your code as an example, I was trying to do the following:
<component:bicycleCategoryList categoryHolder="#{selectBicyclePageBean}">
<f:ajax event="someCustomEvent" render="@form"/>
</component:bicycleCategoryList>However I get the following exception:
<f:ajax> Error: enclosing composite component does not support event someCustomEventIn the FacesComponent, I did implement ClientBehaviorHolder. The someCustomEvent would be fired after an internal <f:ajax> is called. For example:
<f:ajax onevent="handle_onevent"/>Then:
function handle_onevent(data) {
if (data.status == "success") {
var evt = document.createEvent("Events")
evt.initEvent("someCustomEvent", true, true);
this.dispatchEvent(evt);
}Any help would be very appreciated. Thanks! -
Comfortabl​e Scope Component?
Hello all,
I am looking for a comfortable Scope Component for use in LabView that goes beyond a strip chart. The following is what I need:
Possibility to use marker liners 2 for x- and 2 for y-direction. The differences will be shown and updated while moving a marker line.
Similarly, points should be available for Minimum /Maximum values etc.
The signal to be shown comes from the serial port at 115 bps, so the graph has to be fast enough.
Possibility to zoom in and out.
Possibility to stop the recording and to save the waveform.
Possiblity to cut the curve (with cutting lines) and to re-save the cut curve.
Possibility to edit the graph.
I would like to load the waveform and have the same possibilities again (zoom, cutting, moving markers etc.)
Is something like this available for LabView? It can also be an ActiveX Component. Or sombody knows of a c/c++/.net library, whatever.
I use LabView 7.1
Best Regards
JohannesHi Johannes,
Sure, everything of the points you wrote is possible within LabVIEW.
You just have to use the Waveform Graph with it's cursors (you can set several coursors for one graph), where you can read out the current cursor position of every cursor using a property node. Exactly you will get an array of clusters which are the several corsors and there attributes like the x and y position. Then you can read out the positions of every corsor, substact them to become the difference. There are also functions available in LabVIEW for min and max values e.g. of an array. Zooming is also possible with the waveform graph. The methode to cut/save/reload the curve will depend on the datatype you are working. If it is an array you can use the different array functions to e.g. cut the curve and save only the resulting values.
The attached screenshot shows a little example for getting the difference between two cursors position and also the content of one cursors cluster.
Hope this helps, Christian
Attachments:
cursor cluster.jpg 34 KB -
Command Link in the af:table Component can not Work in the Request Scope
Actually, the problem is that when we click on the command link, the action method #{overview.goToLinkAction} is not triggered.
Here is the codes of action method "goToLinkAction" on the backing bean:
public String goToLinkAction() {
String linkString = (String) AdfFacesContext.getCurrentInstance()
.getProcessScope().get("linkString");
System.out.println("Link String is: " + linkString);
return "";
The data object list "listOfTransefer" for af:table is composed first time when the page is initialized.
public void onPageLoad() {
this.listOfTransfers = composeListOfTransfers();
But when the commandlink or commandbutton is clicked to pose the form, this onPageLoad method is ignored by using PagePhaseListener:
public void beforePhase(PagePhaseEvent event) {
FacesPageLifecycleContext ctx =
(FacesPageLifecycleContext)event.getLifecycleContext();
if (event.getPhaseId() == Lifecycle.PREPARE_MODEL_ID && needReload()) {
bc = ctx.getBindingContainer();
onPageLoad();
bc = null;
public final boolean needReload() {
if (!isPostback())
return Boolean.TRUE;
else
return alwaysReload();
protected boolean isPostback() {
return Boolean.TRUE.equals(resolveExpression("#{adfFacesContext.postback}"));
That means the method "onPageLoad()" may not be invoked when the commandlink is clicked.
Is there any way to resolve this problem without changing the scope of the backing bean to "session"?
Your response will be very helpful for us.
ThanksHi,
if you implicitly say that this works if the managed bean is in session scope then the problems seems to me that one of your evaluation criterias is reset in the request scope, which I think most likely is the needReload() method. Did you add debug statements to the methods to see where exactly it gets stuck?
Frank -
How to make a global scope component to be thread safe?
One of my global component preserves states in its member variables, I am afraid that it's might messed up in multi-threading conditions, so how to make a nucleus global component to be thread safe?
Edited by: user13344577 on Jul 14, 2011 9:45 AMHi,
Just to help integrate Shaik's and my own seemingly contradictory replies:
If the member variables in your global component actually need to be globally available, so that multiple threads/sessions need to seem the same data, then you need to use synchronization or some scheme to make this data thread-safe when updating it. If the member variables are non-global data and are simply for convenience of having data available for multiple method calls or something like that, then you should do as I said (don't use synchronization) and use one of my suggestions to avoid this.
I have seen customers frequently do what I replied about and store non-global data in a global component, and Shaik simply interpreted what "user13344577" is trying to do differently. Clarification is needed to know which of our answers better applies.
Thanks.
Nick Glover
Oracle Support for ATG Products -
Scope of component session and http session
Hi,
I wish multiple iviews to share the same information. I am unsure however of the scope of portalcomponentsession, as opposed to http session. I have read the docs, and they are unclear as to the life and scope of these 2 sessions within portal. Which one is tied to the user? And which one is available over multiple iviews.
I would appreciate any help with this
Thanks
MarianaHi Mariana,
> I am sorry
No problem at all
> I did not want to close the topic by mistake
Just for explanation: If you give ten points (they call it blue, my eyes say black), this star is marked in the overview and somehow displaying "solved". In addtion, if you have marked a question as question, you can mark it as answered. As long as you don't do one of both things, you can reward points (2, 6) also in between without trimming your chances to get additional answers.
> I did not de-mark the question,
> I just replied to the post.
When you initially opened the thread (that was no reply), it <i>seems</i> that you've de-marked this thread as question (the standard is: it is a question).
Anyhow, some people seem to have made the experience that they definitely did not de-mark the thread as question, but it wasn't marked as question, anyhow.
In this case, a short and friendly mail to [email protected] with the problem stated and alink to the thread concernced will help to repair everything...
Best regards
Detlev
Maybe you are looking for
-
How to use video camer as Webcam?
I have a Sony PD150 and want to use it as a webcam. Does anybody know how to do this? Can this be accomplished with some free software? Thanks chephoto
-
Hi all, I'm getting the following error message: "The file "iTunes Library" cannot be read because it was created by a newer version of iTunes" Now if I insert my iPod shuffle, iTunes will load. If I just click on it I get the error message. I have i
-
Planning and Scoping- Data conversion and testing
hello Gurus Good people i'm looking for your help in these areas..... 1) Planning and scoping for data conversion....we will be in the process of acquiring information from the client soon. So, what sort of information or questions do i need to get f
-
IMessaging offline - unable to sign in
For several days now, I have been unable to sign in to iMessaging on my MacBook Pro. I did not sign out, the program just decided that I was offline as some point while my laptop was "sleeping". *iMessaging is working fine on my iPhone and iPad. When
-
if anyone can help me with this i would be so greatful, my son is one month old and my wife is heart broken the first month of his life has disappeared from her phone.