Consider I have an enum, which I have coded today. What are the possible ways to extend its functionality, or perhaps add more variables to it, on a later date?
Will partial enums do the trick?
I am having the following
<form action="<%=Url.Action("PasswordDetails",new{Controller = "User"}) %>" method="post" name="PasswordForm" id="PasswordForm" enctype="multipart/form-data">
However, the $("#PasswordForm").submit(function() {
if (validate())
return true;
else
return false;
}); isn`t being passed through.
What is wrong?
I have an html form whose action should be set dynamically throught javascript. How do i do it? Here is what i am trying to do:
<script type="text/javscript">
function get_action() { // inside script tags
return form_action;
}
</script>
<form action=get_action()>
...
</form>
Java lets you create an entirely new subtype of Throwable, e.g:
public class FlyingPig extends Throwable { ... }
Now, very rarely, I may do something like this:
throw new FlyingPig("Oink!");
and of course elsewhere:
try { ... } catch (FlyingPig porky) { ... }
My questions are:
Is this a bad idea? And if so, why?
What could've been done to prevent this subtyping if it is a bad idea?
Since it's not preventable (as far as I know), what catastrophies could result?
If this isn't such a bad idea, why not?
How can you make something useful out of the fact that you can extends Throwable?
So I have an Apple Airport Extreme base station that I use to create a wifi network at my house. But on a separate story from this station i have a PC (running Windows 7) that does not have a wireless card. Luckily, I have another Airport Extreme Base Station, so I figured I'd have my second station "extend" the existing network. I asked Apple if this was possible, which it was, and walked through the setup wizard to extend the network. Then I ran an ethernet cable from the Station to my PC. However the PC refuses to connect to the Internet. It says it can access the network, "Unidentified Network (Limited Connectivity)", but that's it. It tells me that my computer does not have an IP address. I tried running the cable to another computer (my Apple MacBook Pro) and got a similar error. Any thoughts?
I'm trying to extend Object functionality this way:
Object.prototype.get_type = function() {
if(this.constructor) {
var r = /\W*function\s+([\w\$]+)\(/;
var match = r.exec(this.constructor.toString());
return match ? match[1].toLowerCase() : undefined;
}
else {
return typeof this;
}
}
It's great, but there is a problem:
var foo = { 'bar' : 'eggs' };
for(var key in foo) {
alert(key);
}
There'll be 3 passages of cycle.
Is there any way to avoid this?
I would like to add some controls to the SketchFlow player. For example, I would like to add a combo box with a list of values for a specific variable, and selecting a value will make a specific screen/state show up in the SketchFlow player canvas. Is this possible? I have seen that using the PlayerContext allows access to some controls/events in the Player, but I am not sure how extensible the Player itself is.
I have to pass some parameter from an action to another action,for example to keep trace of an event.
What is the best way to do that?
I would not use session parameters. Thanks
Due to a requirement in my current project, I have to build a configuration manager to handle configurations that merge local config info with database one.
Custom configuration doesn't fit my needs, problem is that I don't know what's the type before loading certain information, for example:
Loading database information I will able to know what's myhandler's type. Not previously. So I thought to write my own handler but I can't let set blank as type for sections, in fact .net requires to know what's the type to match myhandler nodes. I'm thinking on building a different parser to read XML nodes but I would prefer to match this structure.
I've not found any information to do that yet, is there any way? Can I extend or hook up something into the framework to be capable of loading on-the-fly types and validate nodes?
Thanks in advance.
Hello. My application is a product which will have reporting capabilities. The product, when in production, is expected to have several ad-hoc report defined by the end users.
I am looking for a platform that can be tailored to harness the business entities and extend reporting capabilities (definition & execution) to the end user.
Here are some constraints:
From the usability standpoint, I like what MS Access reports offer. But of course it is not suitable for the target web application. However, it certainly is a source of inspiration usability wise.
Cost is a constraint. So something recommended from open source world will be appreciated. Otherwise too I'd like to know.
The product in question is somewhat 'generic' in nature.
Mine is a ASP.Net platform.
Hi,
I'm very new to Kohana and I'm trying to make a project in kohana 2.x,
in my previous projects i had created a Base controller which used to extends Controller. and all other controller to Base_Controller.
in Kohana I'm facing the problem. here is my structure.
class Base_Controller extends Template_Controller
class Home_Controller extends Base_Controller
both these Controllers are in application/controller folder
Fatal error: Class 'Base_Controller' not found in /home/myadav/public_html/innteract/innteract/controllers/home.php on line 2
Hey there,
actually I thought I was trying something really simple. ControllerClassNameHandlerMapping sounded great to produce a small spring webapp using a very lean configuration. Just annotate the Controller with @Controller, have it extend AbstractController and the configuration shouldn't need more than this
<context:component-scan base-package="test.mypackage.controller" />
<bean id="urlMapping" class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" />
to resolve my requests and map them to my controllers. I've mapped the servlet to "*.spring", and calling
<approot>/hello.spring
All I ever get is an error stating that no mapping was found. If however I extend the MultiActionController, and do something like
<approot>/hello/hello.spring
it works. Which somehow irritates me, as I would have thought that if that is working, why didn't my first try? Does anyone have any idea? The two controllers I used looked like this
@Controller
public class HelloController extends AbstractController {
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView modelAndView = new ModelAndView("hello");
modelAndView.addObject("message", "Hello World!");
return modelAndView;
}
}
and
@Controller
public class HelloController extends MultiActionController {
public ModelAndView hello(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView modelAndView = new ModelAndView("hello");
modelAndView.addObject("message", "Hello World!");
return modelAndView;
}
}
Is it possible to send POX (plain old xml) into an action and have that action perform model binding to an object for you. Have seen this done with JSON but dont see anyone doing this with xml.
Here's what I am looking to accomplish, I have a class that has an enum of some values and I want to subclass that and add more values to the enum. This is a bad example, but:
public class Digits
{
public enum Digit
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
}
}
public class HexDigits extends Digits
{
public enum Digit
{
A, B, C, D, E, F
}
}
so that HexDigits.Digit contains all Hex Digits. Is that possible?
Hi,
I have some problems to delete temporary folder and files on my server when users not finish some action in webpages and quit to other webpages. Initialy at Page Load folders are created to allow the user to load files.I have tried implementing destruction during Idisposable without success. Could someone point the best method to delete folders and files when user quit the page with no action or cancel button. Thanks.
Hi,
I've a very basic ASP.NET MVC application that uses the default routing. Now I need to route all the requests that comes with out a specific URL to one action with a single parameter.
Examples:
www.myapp.com/2374982
www.myapp.com/3242342
should be routed to the same action:
public ActionResult ViewById(intid) ....
Thanks,
Eden
I'm overriding the handleRenderResponse method defined in com.sun.facelets.FaceletViewHandler:
protected void handleRenderException(FacesContext context, Exception ex)
I'm overriding this method so I can redirect the user to a custom error page (which contain the desired look and feel and other stuff). This is the way I'm trying to
String errorPage = "/error.xhtml";
String contextPath = context.getExternalContext().getRequestContextPath();
String errorPagePath = contextPath+errorPage;
context.getExternalContext().redirect(errorPagePath);
The previous code is what I'm using to perform the redirect to this custom error page. Anyway, when I perform the redirect I'm prompted with a download dialog (this is with Internet Explorer, in Firefox the page does not display properly or as I would expect). I tried changing "/error.xhtml" to "/error.jsf" but in that case I get a 404 error.
Somehow I think that the XHTML file is not being handled to the Facelets ViewHandler after the redirect, if I open the downloaded xhtml file I can see that the EL expressions were not resolved and the the ui tags were not handled. I don't have problems with other pages in my application, only when doing the redirect programatically.
Important data from my web.xml:
facelets.VIEW_MAPPINGS is set to *.xhtml
javax.faces.DEFAULT_SUFFIX is set to .xhtml
servlet-mapping for the "Faces Servlet" is ".jsf" and "/faces/"
I'm trying to extend my controllers with a global base controller as such:
class BaseController extends Zend_Controller_Action {
// common controller actions
public function listAction() {
// do stuff
}
}
class IndexController extends BaseController {
// index controller specific actions
}
class LoginController extends BaseController {
// login controller specific actions
}
But I get this error:
PHP Fatal error: Class 'BaseController' not found in /var/www/Zend/project/application/controllers/IndexController.php on line 3
Any ideas on how to get Zend to "see" this controller?
Hi.
I'm trying to add some extended error codes to the event log but I get the following error.
The description for Event ID ( 109 )
in Source ( PumpServer ) cannot be
found. The local computer may not have
the necessary registry information or
message DLL files to display messages
from a remote computer. You may be
able to use the /AUXSOURCE= flag to
retrieve this description; see Help
and Support for details. The following
information is part of the event: The
event log file is corrupt..
The message file looks like this and I added the one on the end:-
<---snip--->
MessageId=
SymbolicName=EVMSG_BADREQUEST
Language=English
The service received an unsupported request.
.
MessageId=
SymbolicName=EVMSG_DEBUG
Language=English
%1
.
MessageId=
SymbolicName=EVMSG_STOPPED
Language=English
The service was stopped.
.
MessageId=
SymbolicName=EVMSG_INVALIDLICENCE
Language=English
The service does not have a valid licence. Initialization failed.
.
It compiles fine. The mc program is running over this file and producing a header file of the same name with my new message id showing.
//
// MessageId: EVMSG_INVALIDLICENCE
//
// MessageText:
//
// The service does not have a valid licence. Initialization failed.
//
#define EVMSG_INVALIDLICENCE 0x0000006DL
Any ideas why it's not finding my message? All the others work.
I build my action for create image thumbs, and I want add to the end of action auto rotate to my thumb.
My question is: How add rotate with random angle from -45 to 45 degree?
I'm starting to use pelican with reStructuredText rst page format. I have custom javascript (jQuery) things that I'd like to control with div attributes like data-default-tpl="basename" with nested content.
What to extend and what. I've looked at Directives and nodes, but I just can't wrap my head around how to do it.
.. rstdiv:: class1 class2
:name: namessid
:extra: thisIsMyextra
.. rstdiv:: nested class3
:name: nestedid
:extra: data-default-tpl="basename"
some text
.. container:: This is normal rst container
:name: contid
text
From rst to html with pelican.
<div id="nameisid" class="class1 class2" thisIsMyextra>
<div id="nestedid" class="nested class3" data-default-tpl="basename">
some text
</div>
</div>
<div id="contid" class="container This is normal rst container">
text
</div>
I have an object that needs to be serialized to an EDI format. For this example we'll say it's a car. A car might not be the best example b/c options change over time, but for the real object the Enums will never change.
I have many Enums like the following with custom attributes applied.
public enum RoofStyle
{
[DisplayText("Glass Top")]
[StringValue("GTR")]
Glass,
[DisplayText("Convertible Soft Top")]
[StringValue("CST")]
ConvertibleSoft,
[DisplayText("Hard Top")]
[StringValue("HT ")]
HardTop,
[DisplayText("Targa Top")]
[StringValue("TT ")]
Targa,
}
The Attributes are accessed via Extension methods:
public static string GetStringValue(this Enum value)
{
// Get the type
Type type = value.GetType();
// Get fieldinfo for this type
FieldInfo fieldInfo = type.GetField(value.ToString());
// Get the stringvalue attributes
StringValueAttribute[] attribs = fieldInfo.GetCustomAttributes(
typeof(StringValueAttribute), false) as StringValueAttribute[];
// Return the first if there was a match.
return attribs.Length > 0 ? attribs[0].StringValue : null;
}
public static string GetDisplayText(this Enum value)
{
// Get the type
Type type = value.GetType();
// Get fieldinfo for this type
FieldInfo fieldInfo = type.GetField(value.ToString());
// Get the DisplayText attributes
DisplayTextAttribute[] attribs = fieldInfo.GetCustomAttributes(
typeof(DisplayTextAttribute), false) as DisplayTextAttribute[];
// Return the first if there was a match.
return attribs.Length > 0 ? attribs[0].DisplayText : value.ToString();
}
There is a custom EDI serializer that serializes based on the StringValue attributes like so:
StringBuilder sb = new StringBuilder();
sb.Append(car.RoofStyle.GetStringValue());
sb.Append(car.TireSize.GetStringValue());
sb.Append(car.Model.GetStringValue());
...
There is another method that can get Enum Value from StringValue for Deserialization:
car.RoofStyle = Enums.GetCode<RoofStyle>(EDIString.Substring(4, 3))
Defined as:
public static class Enums
{
public static T GetCode<T>(string value)
{
foreach (object o in System.Enum.GetValues(typeof(T)))
{
if (((Enum)o).GetStringValue() == value.ToUpper())
return (T)o;
}
throw new ArgumentException("No code exists for type " + typeof(T).ToString() + " corresponding to value of " + value);
}
}
And Finally, for the UI, the GetDisplayText() is used to show the user friendly text.
What do you think? Overkill? Is there a better way? or Goldie Locks (just right)?
Just want to get feedback before I intergrate it into my personal framework permanently. Thanks.
I have class named AbstractUser, which is annotated with @MappedSuperclass. Then I have a class named User (@Entity) which extends AbstractUser. Both of these exist in a package named foo.bar.framework. When I use these two classes, everything works just fine. But now I've imported a jar containing these files to another project. I'd like to reuse the User class and expand it with a few additional fields. I thought that @Entity public class User extends foo.bar.framework.User would do the trick, but I found out that this implementation of the User only inherits the fields from AbstractUser, but nothing from foo.bar.framework.User. The question is, how can I get my second User class to inherit all the fields from the first User entity class?
Both User class implementation have different table names defined with @Table(name = "name").
I want to create a class that takes two parameters. One should be typed simply as T. The other should be typed as something that extends both T and SomeInterface. When I attempt this with
public class SomeClass<T, S extends SomeInterface<T> & T>
then Java complains with
"The type T is not an interface; it cannot be specified as a bounded parameter"
and if instead I attempt to create an interface for S with
public interface TandSomeInterface<T> extends SomeInterface<T>, T
then Java complains with
"Cannot refer to the type parameter T as a supertype"
Is there any way to do this in Java? I think you can do it in C++...?