i am configured the zk with struts 1 . i created a list and set in the session.
List<String> nameList = new ArrayList<String>();
nameList.add( "xxx" );
nameList.add( "yyy" );
nameList.add( "nnn" );
nameList.add( "ddd" );
request.getSession().setAttribute("NAMES_LIST", nameList);
now from the zul file i am trying to get the session value. How do I do that?
You have to call getNativeSession on the zk session then cast that to be a javax.servlet.http.Session which the one that struts is using.
Trying to mix zk with struts is missing the point. With zk do whatever you need to do and update the zk components and the browser will automatically be updated. Putting data into old style forms to send to the server then update the page is old style programming and less efficient than zk event driven programming where you just update the zk desktop (not bothering to think about pages) and the screen is updated. Your uses can work all day with rich behavior without ever posting a form to interact with struts.
ZK session is a wrapper object on top of HttpSession, so the access is the same. With EL, just uses sessionScope, e.g., ${sessScope['xxx']}.
In Java, just use getAttribute. To get the session object, you can invoke Sessions.getCurrent().
Hope it helps.
Related
Ok, Here is the problem.
At the time user signup, user need to provide info such as:
-Email:______________ -UserName:____________
-FName:______________ -LName:_______________
-Address:____________ (User can have option to update Address lately)
....
-Captcha:__________
[Sign Up] [Reset]
Now suppose that user already got an account & they want to modify their info, then the Gui Could be 40% similar to the the above one.
-FName:______________ -LName:_______________ [Update Name]
-Address:____________ [Update Address]
....
My question is how to design GWT Gui in such a way that we can reuse the Gui components and the Action in both situations?
Maybe put all GUI into 1 page & have 2 different params: 1 for handling Signing Up Ex: #profile;actionParam="signup", & the other for Updating Profile Ex:#profile;actionParam="modify".
We can also use PresenterWidget but I think PresenterWidget is for using the exact same code everywhere, but in my case the Gui need to be modified a bit.
In Java we can do like Parent and Child Inheritance, but I am not sure if we an do similar things like that in GWT?
Can u find a better solution?
You can use the exact same view (widget) and simply hide some fields based on your criteria. You can also group these extra components in one container, so you can hide/show them with a single call:
.newUserPanel.setVisible(user == new);
You can extends widgets in GWT - all of the "standard" widgets extend and implement something - but in this use case the benefits are probably too small to justify two separate views/widgets. But it's possible if you decide to go this route.
IS there a way to add/initate a comment ( e.g. $dom->createComment ... ) such that it comments out an entire block of xml tags. Basically I want to turn-off the content between the comment.
For example, it would look like this:
<TT>
<AA>keep</AA>
<!-- comment to blocking
<BB>hideme1</BB>
<CC>hideme2</CC>
-->
<DD>d's content is good</DD>
</TT>
Actually this question is a pre-cursor to my attempt to figure-out a method to be able to markup/label/identify the changes to an xml files in support of new client software functionality, but be able to have the ability to remove / back-out these xml changes in the rare event the client needs to fall back to the previous software version (and no I can't just simply point back to the original xml file because the client is allowed to make minor modifications to existing node text values). This is all going to be controlled via a perl script and LibXML's core modules (I can't use modules the client doesn't have).
So basically I've identified three possible types of xml changes as a result of new client sw functionality:
1.) ADD new element node(s) (typically to support new sw functionality)
2.) DELETE element node(s), or blocks of (would be rare, but never-the-less a possibility)
3.) CHANGE node text values (rare, but the new sw may require a new value)
For all three types, the client needs the ability to back out the changes. One thing I was thinking to use is ATTRIBUTES since the existing xml files don't use them. For example, for an ADD change type, I could include an atribute like 'ADD="sw version 4.1"' . This way if it needs to be removed, I could just simply have the perl script find those attribute strings and delete them (using LibXML methods). Same thing with CHANGE change type - I could use an attribute like CHG="newvalue_oldvalue", then again use straight perl (or LibXML) to switch back the value based on the contents of the attribute. The DELETE change type is giving me a problem though (as welll as the others lol!). I want to be able to "keep" the deleted lines in the xml file soley for the purposes if the sw falls back a version (at some late point the perl script could eventually cleanup/delete them).
I know this is a lot, I'm new to LibXML (but not to perl). I was just wonder if any of you have any thoughts as to how to go about it or seen anything resembling this kind of request ... I'd be grateful for any kind of advice! Thank you...
We're running servers with JBoss on them and log4j for errors. I've been asked to come up with a way to log things like freememory and active thread group count so that we can monitor these without having to go through the jboss console. However, I've been told that it'd be preferred if I could do this without having to make any changes to the existing servers. My original thought was to change the log4j.xml to persist the relevant data to a database to parse out and display later, however now I really don't know.
Is there any other way, without installing a 3rd party app, to automatically grab information from a jboss server and persist it? Or should I just keep fighting to be allowed to modify the log4j xml?
Also, is this even possible? I've looked all over for examples but nowhere has specifically stated that you can use log4j to also log system stats.
Hunter;
Assuming there are no network impediments and JMX remoting has not been disabled in any way, you can remotely monitor these values using the JMX API. Here's some Groovy code to do this, but you can translate this to Java easilly.
import javax.management.*;
import javax.naming.*;
Properties p = new Properties();
p.put(Context.PROVIDER_URL, url);
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put("jnp.disableDiscovery", "true");
ctx = new InitialContext(p);
contexts.put(url, ctx);
mbeanServer = ctx.lookup("/jmx/rmi/RMIAdaptor");
// Lookups here
Put /client/jbossall-client.jar in your classpath.
Now just scroll through JMXConsole (on a Dev server if you must) and pick the attributes and ObjectName you want to collect. For example, extending the example above, to get FreeMemory (groovy again):
import javax.management.*;
def objectName = new ObjectName("jboss.system:type=ServerInfo");
def freeMem = mbeanServer.getAttribute(objectName, "FreeMemory");
In your JMXConsole, that maps to this MBean:
and to this attribute in that MBean:
So if you set up a scheduler to collect this data from time to time, you can write it to a DB, put it in an email or whatever.
Make sense ?
I've went through the Jobeet Tutorial for integrating Zend Lucene into a symfony (1.4.8) project in order to add search capabilities into my frontend of my site (through indexing). Among others, the key concept is to use updateLuceneIndex during model's save action (needs to be overridden) in order to create/update the index of the specific entry.
My model has i18n fields, some of which (i,e name, title) I want to be inserted in the index. Everything works as expected but when it comes to save the i18n fields into the index all I get is blank values ($this->getName() returns empty string). I'm inspecting the created index with the Luke.
I ended up that this has nothing to do with the Zend Lucene but with symfony. It seems that during save the information for i18n fields isn't available (or is it?). I've also tried hook up the update during preSave(), postSave() but no avail.
So I want to ask how am I supposed to get my model's i18n field values during the save action in order to update the index accordingly?
Important note: This happens only during doctrine:data-load task. If I manually insert or update a record the index gets updated accordingly.
One last related question. It would be nice if I could save different keywords for each of the languages of the field of the model. How can I get the different values for each field's language inside the model?
The reason of this strange behaviour of Symfony is that when you are loading fixtures via cli, it has no context loaded (for instance when you try to get context instance sfContext::getInstance(), youll get "context instance does not exists" error exception).
With no context instance available, there is no "current culture" and with no current culture, there is no value of i18n fields.
The symfony context actualy supports all I18N functionalities with current User culture ($currentUserCulture = sfContext::getInstance()->getUser->getCulture()).
This all means 2 things:
You cant use symfony "current user culture" capabilities while you are
in cli session
If you needs to have sfContext::getInstance() somewhere in your
code (especialy in the models), you have to close it into condition to avoid any troubles with unexpected and hard to find exceptions while in cli
Example of getting current culture in model class (it will not pass condition while in cli):
if (sfContext::hasInstance()) {
sfContext::getInstance()->getUser()->getCulture();
}
So when you cant use Symfony i18n shortcuts (like $record->getName()), you have to work around it.
In Your symfony1-doctrine models you always have $this->Translation object available.
So you can access your translation values object via something like $this->Translation[$culture].
Its up to you to work with that, you can use your default culture $this->Translation[sfConfig::get('sf_default_culture')], or interate trough all your supported cultures from some global configuration (i recommends you to set it in one of your configuration files globaly accross of all apps - maybe /config/app.yml).
Example of getting $record Translation object in any situations:
if (sfContext::hasInstance()) {
$translation = $this->Translation[sfContext::getInstance()->getUser()->getCulture()];
}
else {
$translation = $this->Translation->getFirst();
// or: $translation = $this->Translation[$yourPreferedCulture];
}
// you can access to modified fields of translation object
$translationModified = $translation->getModified();
Being fairly new to Zend Framework, I've been reading and trying out various tutorials on the web and books I've purchased. One thing all the tutorials do is hard code certain values into into the bootstrap or other code. For example, setting the title:
$this->_view->headTitle('MySite');
I realize this can be set in the application.ini file, but I don't think that is appropriate either if you are distributing the application to other sites.
I would be interested in hearing ideas where application specific settings are set in the application.ini file and loaded:
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH.'/configs/application.ini'
);
Then somewhere in the bootstrap, checking for a config.ini file and adding these to currently existing application config array, and if config.ini does not exist, retrieving such site specific configs from a database and writing the config.ini file (Obviously the file deleted and rewritten if a value is changed in the database).
I don't need to see how the file is written or what not... just a general idea of how others are handling such things. Or provide different ideas of doing this?
I would rather end up using something like this when setting various site specific configurations:
$this->_view->headTitle($config->site->title);
Hope this makes sense :-)
It depends a bit what kind of data you want in your config files, and how you are reusing your application on different sites.
Although it's normal to pass the filename to your config file as the second parameter to Zend_Application, you can also pass a Zend_Config object. Zend_Config itself makes it very easy to merge together multiple config files, so in your public/index.php you could do something like this:
$defaultConfigFilename = APPLICATION_PATH . '/configs/application.ini';
$siteConfigFilename = APPLICATION_PATH . '/configs/site.ini';
// Create config object, using site-specific data if available
$config = new Zend_Config_Ini($defaultConfigFilename, null, true);
if (file_exists($siteConfigFilename)) {
$siteConfig = new Zend_Config_Ini($siteConfigFilename);
$config->merge($siteConfig)
->setReadOnly();
}
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
$config
);
this will look for a site.ini file, and if it exists, merge it with the application ini. Then it will bootstrap the application as normal.
Another way that I've used myself recently is to just keep application.ini as minimal as possible (e.g. only bootstrap class name and location), and then have an _initSite() method in my bootstrap class that creates a Site object using data from the database. It then reads in config data from a ini file, and stores this in the Site object. I then have a site resource that I can access elsewhere in my application, for example to do $view->_headTitle($site->config->title); like in your example above.
I hope this gives you some ideas. ZF is pretty flexible!
Remember, that you may pass many config files to Zend_Application, not just application.ini,
so this might be the best in your case.
If you heavily rely on configs, you may be interested on creating additional application resources, using specific setting you provide to the Zend_Application via config.ini.
But I bet, it the future, you will store these options in the database and allow end user to modify them.
In the simplest case, solution I prefer:
// in the layout.phtml
$this->render('head.phtml');
...
$this->render('footer.phtml');
And in the footer and head configuration specific to the site.
Fast and easy to maintain.
in view_script.phtml
$this->headTitle()->prepend($config->site_title);
where the trouble is?