How to get the owning bean given a java object
Hi, is there any way - for a just-created bean instance - to know on behalf of which bean this object has been created ?
In other words, going back from the java object to the bean symbolic name, as described in a faces-config managed-bean chunk (just the opposite of resolveVariable) ?
You want to get the definied managed bean name inside the backing bean?
If so, call this inside the backing bean: private String getManagedBeanName() {
String managedBeanName = null;
HttpServletRequest request =
(HttpServletRequest) FacesContext
.getCurrentInstance()
.getExternalContext()
.getRequest();
// Lookup bean in request scope.
Enumeration requestAttributeNames = request.getAttributeNames();
while (requestAttributeNames.hasMoreElements()) {
String requestAttribute = (String) requestAttributeNames.nextElement();
Object object = request.getAttribute(requestAttribute);
if (this.equals(object)) {
managedBeanName = requestAttribute;
break;
if (managedBeanName == null) {
// Bean is not in the request scope. Lookup it in session scope.
Enumeration sessionAttributeNames = request.getSession().getAttributeNames();
while (sessionAttributeNames.hasMoreElements()) {
String sessionAttribute = (String) sessionAttributeNames.nextElement();
Object object = request.getSession().getAttribute(sessionAttribute);
if (this.equals(object)) {
managedBeanName = sessionAttribute;
break;
return managedBeanName;
}
Similar Messages
-
How to get the current function name in java
How to get the current function name in java.
In c it is done as
printf("%s",__func__);
Thanx in advance.j0o wrote:
System.out.println("Class Name: " + new Exception().getStackTrace()[0].getClassName() +
"/n Method Name : " + new Exception().getStackTrace()[0].getMethodName() +
"/n Line number : " + new Exception().getStackTrace()[0].getLineNumber());
I pointed the OP at this approach yesterday in one of his multi-posts. I still have not been given my Dukes! -
In OBIEE 11G, how to get the special parameter created by JAVA?
Hi Experts,
In OBIEE 11G, how to get the special parameter created by JAVA?
For example:
In JAVA , it has set one parameter named 'test'.
So how to get the parameter in filter area in OBIEE?Hi Kobe,
No P2 holds the parameter name like PresentationTable.ColumnName, in your form you may go for complete name or just column name and before submitting the form you can define the Action url.
I would suggest to read section 6.3.2.1.
ex:
<SCRIPT LANGUAGE="JavaScript">
changeAction(url) {
var TestVar = form.inputbox.value;
document.this_form.action="saw.dll?Go&Path=/Shared/Test/SB2&Action=Navigate&P0=1&P1=like&P2=Customers.Region&P3="+TestVar;
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="myform" ACTION="" METHOD="GET">Enter something in the box: <BR>
<INPUT TYPE="text" NAME="inputbox" VALUE=""><P>
<INPUT TYPE="button" NAME="button" Value="Click" onClick="changeAction(this.value)">
</FORM>
If helps pls mark.
Edited by: veeravalli on Oct 24, 2012 10:25 AM -
How to get the current GMT time in java
Hi,
How to get the current GMT time in java
ThanksSystem.getCurrentTimeMillis() or new Date().
[url http://www.javaworld.com/jw-12-2000/jw-1229-dates.html]Calculating Java dates: Take the time to learn how to create and use dates
[url http://www.javaalmanac.com/egs/java.text/FormatDate.html]Formatting a Date Using a Custom Format -
Dear All
How can I read out the own IP-Address from my MIDP1.0 after I have opened a TCP socket.
I haven't found any method/way in J2ME so far to get the own address that the GSM-provider has assigned to my mobile.
Any hints or ideas would be appreciated
Regards
SektionschefHello,
that is not possible because your mobile phone does not have an actual ip address, at least as far as I understand it. The gprs or hsdc gateway does and then it converts all traffic to some low level protocol which it uses to route the right stuff to your phone.
A simple test would safice, write a simple servlet which logs all connections and then connect to it from your phone. Then disconnect your gprs/hsdc connection and connect again. Try to access the servlet and it will show the same IP address, the one of the gateway facilitating the communication.
Hope this helps.
Regs jP -
How to get the results for given Bind Variable
Hi
Can any one help me how to get the result rows from the View Object after executing the view object query by setting bind variable?
snippet as follows
viewObject.setNamedWherClauseParams("name","hei");
viewObject.executeQuery();
How to get the results from viewObject is my question..?
Thanks in advanceShould be something like
while (vo.hasNext()){
Row r = vo.next();
r.getAttribute....
You might want to read the "most commonly used methods" appendix in the ADF Developer Guide. -
How to get the Current Date in webdynpro java
Hi Experts,
In my project i have two date input fields called
1)Start Date
2)End Date
and one Absence type input field is there. The user wants to set the start Date ,End date and absence type.
How to get the user set values in my project.i.e how to get the user inputs and the started date must be current date of the system and end date must be after the 3 months.
Can any body send code regarding this.
Thanks in advance.
Regards,
Venkat.
Edited by: Venkat5939 on Jan 11, 2011 4:46 PMHello Venkat,
Current Date:
Date date = new Date(System.currentTimeMillis());
For getting the date after three months refer the following threads:
Set date in a date field
Date Function
date format
Hope it helps.
Regards
Nizamudeen SM -
How to get the silverish white color in Java
Hi
I want to know how to get the silver color in Java
I am currently using
R , G , B
setBackground(new color(255,255,255));
I am getting bright white color.
How do I get the polished white(silverish white color) color.
Thank YouRGB Color Chart...
http://www.htmlcenter.com/tutorials/tutorials.cfm/89/General/
perhaps new Color(223,223,255) ??? -
How to get the system32 folder path in java?
how to get the system32 folder path in windows using java code?
Zstar Electronic Co.Ltd, Wholesaler of fire cards for DS/NDSL/NDSi, Provide R4, R4i, DStt, iEDGE, AK2i,M3,M3i,N5
www.zstar.hk -
How to get the own schema data while calling the other schema's Procedure
Hello Experts,
I'm Sanjit, new to OTN forum.
I'm using Oracle 10g 10.1.0.2.0 database. Another user Sush has created one procedure proc_1 like
create or replace procedure proc_1
as
v_total number;
begin
select sum(amt) into v_total from trans_master where dot
between add_months(sysdate,-3) and sysdate;
dbms_output.put_line('last three months total transactions is: '||v_total);
end proc_1;
He has the Trans_master table and having 280 records and I have the same Trans_master table with 430 records
inserted in last 3 months. He has granted execute privileges on the procedure Proc_1 to me. When I call the procedure
I cannot call it directly like my own schema procedures: Exec Proc1;
I am calling like : Exec Sush.Proc1 to get the result. My issue is: when the procedure is called,
it is accessing the data from the Sush schema Trans_master table with 280 records total, but I want
the procedure to get the total amount of transaction of 430 records from my own Trans_master table.
Please resolve my issue which would be a great help. And is there any way to call the procedure of other schema
by not attaching the owner name of the object with it?
Thanks
SanjitPleast take a look at "Definer's rights and invoker's rights" in the following article:
http://docs.oracle.com/cd/E11882_01/timesten.112/e21639/accesscntl.htm#BABDDCHC
I guess you need to define a stored procedure with "invoker's rights".
If this is what you are looking for will have to define it in the stored procedure that you are going to call.
The syntax is as follows:
create or replace procedure <yourprocedure> authid current_user ...
...or (the following is the default, you don't have to use the "authid definer" keywords):
create or replace procedure <yourprocedure> authid definer ...
...hm -
How to get the modified bean classname ?
Hi,
We have a product that persists the beans in an object database.
I am looking for a way a way for a client to know the name of
the WLS implemented bean, dynamically(rather than providing it manually), so that
it can do a query for the bean( in the database).
Seems, like this name iss changing from one version to another.
The dynamic bean names generated in WLS6.1 is not the same as
those for WLS7.0. And WLS5.1 didn't have this behavior.
Are you sure that there is no way we can find it? Maybe, someone
from bea will know.
Thanks,
GurdevHi,
Using the Context interface (listBindings()) you can get all bindings under a
context. One can enumerate through the returned enumeration and go down the tree
if required.
S
"Gurdev Parmar" <[email protected]> wrote:
>
Hi,
We have a product that persists the beans in an object database.
I am looking for a way a way for a client to know the name of
the bean, dynamically(rather than providing it manually), so that
it can do a query for the bean( in the database).
Seems, like this name keeps changing from one version to another.
The dynamic bean names generated in WLS6.1 is not the same as
those for WLS7.0. And WLS5.1 didn't have this behavior.
Thanks,
Gurdev -
How to get the modified bean name in WLS?
Hi,
We have a product that persists the beans in an object database.
I am looking for a way a way for a client to know the name of
the bean, dynamically(rather than providing it manually), so that
it can do a query for the bean( in the database).
Seems, like this name keeps changing from one version to another.
The dynamic bean names generated in WLS6.1 is not the same as
those for WLS7.0. And WLS5.1 didn't have this behavior.
Thanks,
GurdevHi,
Using the Context interface (listBindings()) you can get all bindings under a
context. One can enumerate through the returned enumeration and go down the tree
if required.
S
"Gurdev Parmar" <[email protected]> wrote:
>
Hi,
We have a product that persists the beans in an object database.
I am looking for a way a way for a client to know the name of
the bean, dynamically(rather than providing it manually), so that
it can do a query for the bean( in the database).
Seems, like this name keeps changing from one version to another.
The dynamic bean names generated in WLS6.1 is not the same as
those for WLS7.0. And WLS5.1 didn't have this behavior.
Thanks,
Gurdev -
How to get the page break preview in java
I have an in house report building utility using gridbaglayouts. My reports are coming pretty good but i am unable switch the grids page wise. I tried using the graphics but failed as it cuts the grid in between. The grid bag layout does not return and size(height and width) for the grids. so theoption of getting the heights of grids will not work. Please give me the solution
j0o wrote:
System.out.println("Class Name: " + new Exception().getStackTrace()[0].getClassName() +
"/n Method Name : " + new Exception().getStackTrace()[0].getMethodName() +
"/n Line number : " + new Exception().getStackTrace()[0].getLineNumber());
I pointed the OP at this approach yesterday in one of his multi-posts. I still have not been given my Dukes! -
How to get the hour:minuts:seconds using java
I have table xydata
here i get the gsTime like this 2010-04-21 10:58:40
the above time i want to get only 10:58:40
how to write the java for this
please help me
Thanks in AdvanceProblem of this sort cry out for using regular expressions. It is what they were invented for. If the OP wanted the whole date parsed into a java.util.Date then it would be a different matter and SimpleDateFormat would be the way to go but extracting part of a string is what regular expressions are best at.
In this case, even a regular expression approach is far too complex. Which of the following do you consider the most appropriate ?
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Sabre20100508
public static void main(String[] args) throws Exception
String[] lines =
"2010-04-21 11:01:35",
"2010-04-21 11:01:58",
"2010-04-21 11:02:21",
"2010-04-21 11:02:42",
"2010-04-21 11:03:28",
"2010-04-21 11:03:51"
Pattern p = Pattern.compile("(?<= )\\d{2}:\\d{2}:\\d{2}");
System.out.println("Method 1 :-");
for (String line : lines)
Matcher m = p.matcher(line);
if (m.find())
System.out.printf(" [%s]\n", m.group());
Pattern p = Pattern.compile("\\d{4}-\\d{2}-\\d{2} (\\d{2}:\\d{2}:\\d{2})");
System.out.println("Method 2 :-");
for (String line : lines)
Matcher m = p.matcher(line);
if (m.matches())
System.out.printf(" [%s]\n", m.group(1));
System.out.println("Method 3 :-");
for (String line : lines)
String[] splitLIne = line.split(" ", 2);
System.out.printf(" [%s]\n", splitLIne[1]);
System.out.println("Method 4 :-");
for (String line : lines)
int index = line.lastIndexOf(" ");
System.out.printf(" [%s]\n", line.substring(index + 1));
System.out.println("Method 5 :-");
SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
for (String line : lines)
Date date = parser.parse(line);
System.out.printf(" [%s]\n", formatter.format(date));
System.out.println("Method 6 :-");
for (String line : lines)
System.out.printf(" [%s]\n", line.replaceAll("[^ ]* ", ""));
}My vote goes to method 4! -
How to get the "where used" of a portal object.
Hi folks!
I'm coding a program to get the list of the portal objects where a specific portal object (an iView for example) is used. I found the method getWhereUsedList from IPcdContext but I'm getting some errors.
Is this the best/correct way to get a "where used list"?
Does anyone have an example of how to use this method correctly?
Thanks in advance.
Geraldo.Hi Tanja, thank you very much for your attention.
Following your tips I figured out that the error was occurring during the casting and not during the getWhereUsedList method call. Now, I'm casting to Object. I'd like to cast to a more proper class. During my tests I got an error that showed me that the cast should be to a PcdGlSearchResult class. I couldn't find any javadoc for this class and when I changed the cast to this class I started to get a execution class load error. Please let me know if you have any advice regarding the casting.
private void getWhereUsed1(IPortalComponentRequest request, String id, StringBuffer sb) {
InitialContext iCtx = null;
Object objectId = null;
String tString = null;
Hashtable env = null;
IPcdContext result = null;
env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
env.put(Context.SECURITY_PRINCIPAL, request.getUser());
env.put(Constants.REQUESTED_ASPECT, IPcdAttribute.PERSISTENCY_ASPECT);
try {
iCtx = new InitialContext(env);
result = (IPcdContext) iCtx.lookup(id);
for (NamingEnumeration ne = result.getWhereUsedList(""); ne.hasMoreElements();) {
objectId = (Object) ne.nextElement();
tString = objectId.toString();
sb.append(tString + CR);
} catch (Exception e) {
StackTraceElement[] elements = e.getStackTrace();
for (int i = 0; i < elements.length; i++)
sb.append(elements<i> + CR);
Maybe you are looking for
-
How can I move my apps from one computer to another?
I got a new computer which means I have to sync my Iphone to my new computer. However, this means my apps are going to be deleted off my phone when I do sync it. Does anyone know how to move these apps to my new computer?
-
Disk Boot Failure, Insert System Disk and Press Enter
I have been experiencing an intermittent disk boot failure for the last few months on my HP Pavilion Slimline PC. At first, it would occur once every week or two, typically when the computer would boot up after being in hibernation. After turning off
-
Statutory Compliances (Indian Localization)
Hi All, I've some doubts regarding the Statutory Compliances (Indian Localization) in SBO and I want to share with all you. Anyone who can plz help me. Service Tax · Is tracking invoice wise details and automatically calculating service tax p
-
Album art won't transfer when dragging music to device
Hope I'm not the only one to have noticed this. I recently updated iTunes to v10.6 from 10.0. Since then, any album art that I have manually added in the past no longer shows up on my iPhone or iPod Classic. However, album art that was retrieved via
-
Buddy gave me his Nano 2g!!! mean message on connecting...
So my buddy bought a new iPod and i was in the right place at the right time! I took the machine home and promptly hooked it to my keyboard which didn't work and then it worked on the back of my iMac. When i start iTunes i get an error: The iPod "My