Thursday, 3 October 2013

LWP::UserAgent and HTTP::Request for a POST request

LWP::UserAgent and HTTP::Request for a POST request

In a certain script I tried to write this:
my $ua = LWP::UserAgent->new;
my $res = $ua->post($url, Content => $data);
and got "400 Bad Request". After some reading I tried this:
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new( 'POST', $url );
$req->content( $data );
my $res = $ua->request( $req );
and it worked, but I thought these two should do the same. What am I
missing here? Am I misunderstanding something in the documentation of
HTTP::Request and LWP::UserAgent?
Is there a way to ask LWP::UserAgent to print what it is doing?

Wednesday, 2 October 2013

Complex Regex composition - Regex that match "if"

Complex Regex composition - Regex that match "if"

I'm making a Regex to match hashtags to my project. I want that regex
match hashtags that are separeted by one single space, don't have another
hashtag inside this content and just match a space in the string if this
is followed by any word (except other blank space or #).
I'm really curious to know if I can do something like "if" in regular
expressions and I hope you can help me with this.
So, in:
"#hashtag?!-=_" "#hashhash#" "#hash tag" "#hash tag" "#hash
#ahuhuhhuasd" "#hash "
The regex must match the following sentences:
"#hashtag?!-=_" "#hashhash" "#hash tag" "#hash" "#hash #ahuhuhhuasd" "#hash"
(all hashtag) (one) (another h.)
Actually, this is my code:
#{1,1}\S+\s{0,1}
You can test here this code, but it matches things that isn't desired:
"#ahusdhuas?!__??###hud #ahusdhuads "
The blank space in the end of the string, the 3 '#' inside the string.
none of the following content is desired in this string, just
"#ahusdhuas?!__??"
Glad if you can help me!

Problems with geotools library to create a .jar?

Problems with geotools library to create a .jar?

I have a java project and it works in eclipse then I create a .jar for
this project and when a try to execute the jar the following errors
appears:
If I create the .jar with eclipse: Exception in thread "main"
java.lang.NoClassDefFoundError: org/geotools/data/FeatureSource
If I create the .jar with mvn: Error: no se ha encontrato o cargado la
clase principal client.Client
Thanks

comparing pointer to a negative value

comparing pointer to a negative value

Can i typecast a pointer to a structure to a signed value to return a
different types of errors. Does the C standard allow this or is an
undefined behaviour.
typedef enum lError
{
l_OK = 0,
l_ERROR = -1,
l_ABORT = -2,
l_HALT = -3
}L_STATUS;
typedef struct dataCards
{
int card1;
int card2;
char flag;
}DATACARD;
DATACARD dataCardG;
DATACARD *getCard(int i)
{
if(i == 1)
return &dataCardG;
else if (i == 2)
return (DATACARD *)l_ERROR;
else if (i==3)
return (DATACARD *)l_ABORT;
else
return (DATACARD *)l_HALT;
}
int main ()
{
DATACARD *ptr = NULL;
ptr = getCard(3);
if(ptr < (DATACARD *) 1) /* Is this allowed or undefined behaviour */
printf("Card failed\n");
}
How can i make this condition work?

Getting the JAXB exception like "Two classes have the same XML type name..."

Getting the JAXB exception like "Two classes have the same XML type name..."

Getting the JAXB exception like "Two classes have the same XML type name...",
Here is the exception details:
Exception in thread "main"
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts
of IllegalAnnotationExceptions Two classes have the same XML type name
"city". Use @XmlType.name and @XmlType.namespace to assign different names
to them. this problem is related to the following location: at
com.model.City at public com.model.City com.model.Address.getCurrentCity()
at com.model.Address this problem is related to the following location: at
com.common.City at public com.common.City
com.model.Address.getPreviousCity() at com.model.Address
at
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown
Source) at
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown
Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(Unknown
Source) at
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown
Source) at
com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown
Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
javax.xml.bind.ContextFinder.newInstance(Unknown Source) at
javax.xml.bind.ContextFinder.find(Unknown Source) at
javax.xml.bind.JAXBContext.newInstance(Unknown Source) at
javax.xml.bind.JAXBContext.newInstance(Unknown Source) at
com.PojoToXSD.main(PojoToXSD.java:17)
I took the example like:
package com.model; ---->this package contains 'Address' class and 'City'
class
public class Address {
private String areaName;
private City currentCity;
private com.common.City previousCity;
}
package com.model;
public class City {
private String cityName;
}
Another city class in "com.common" package.
package com.common;
public class City {
private String pinCode;
}
We need to create XSDs and needs to do the Marshalling and unmarshalling
with the existing code in our project(like as above example code), code
does not have any annotations like "@XmlRootElement/@XmlType" and we can
not able to change the source code.
I would like to know is there any solution to fix the above issue or any
other ways to create XSDs and marshaling/unmarshalling(like MOXy..etc)?
It would be great if i can get the solution from any one....May thanks in
advance.
Thanks,
Satya.

Tuesday, 1 October 2013

Multiple and dynamic databases in doctrine 2

Multiple and dynamic databases in doctrine 2

I checked already multiple answers on stackoverflow but couldnt find a
sufficient answer for that problem.
Imagine I have a MAIN database and multiple SLAVE databases. Based on some
information in the MAIN database I will then know which SLAVE database I
will connect to and which table I will use for my model.
As an example:
A Person entity can be connected to a database1234 database using the
table person_india or to database7834 using a table person_uk etc. Which
one I will connect to is decide on runtime and cant be configured before.
What I found so far:
I can directly bind a model to a database.table via
@Entity @Table(name="databaseName.tablename")
So Im able to join over databases. So basically Im ignoring the dbname in
the connection params for the entityManager.
Question:
How to dynamically set the information(database,table) for an entity on
the fly?
Will this affect caching?
If this is not possible in a good manner. Is there any other orm which
will provide me that kind of functionality.
Thanks in advance

How to trigger two function on form submit?

How to trigger two function on form submit?

I have a form when the form is submitted i'll call one javascript function
and action it to to form handler.
<form action="subscribe.php" onsubmit="return form_check(this)"
method="post">
<input type="text" value="">
<input type="submit" value="click">
</form>
Everything Works fine, Now i want to send the same form fields to another
javascript function so i tried like this on submit code
<form action="subscribe.php"
onsubmit="return (form_check(this) & another_script(this))" method="post">
Added & in onsubmit but the function is not triggering when the button is
clicked. I think this is due to the action="subscribe.php" in the form.
I want to send the form value to another javascript function also. how can
i achieve this?

What's a neutral word for "father" and "mother"? – english.stackexchange.com

What's a neutral word for "father" and "mother"? – english.stackexchange.com

Is there a neutral word to refer to "father" and "mother" without the
family connotations? For example, there was a guy who refer to his parents
using the terms "sperm and egg bank": They were my …

Postix dosen't forward to Gmail Yahoo Hotmail

Postix dosen't forward to Gmail Yahoo Hotmail

I have a problem with my Postfix 2.8.4 (Cent OS 6 with Plesk 11.0)
If i sent an email to one of these providers, it will be delivered ok.
If I setup my email to forward all emails to one of these providers:
a. if i sent from an email from the same server, it will be delivered ok
b. If I sent from an email not hosted on the server, the mail will be
stuck in the queue forever.
Below is my main.cf
#
#soft_bounce = no
# LOCAL PATHNAME INFORMATION
#
queue_directory = /var/spool/postfix
# The command_directory parameter specifies the location of all
# postXXX commands.
#
command_directory = /usr/sbin
# The daemon_directory parameter specifies the location of all Postfix
# daemon programs (i.e. programs listed in the master.cf file). This
# directory must be owned by root.
#
daemon_directory = /usr/libexec/postfix
# The data_directory parameter specifies the location of Postfix-writable
# data files (caches, random numbers). This directory must be owned
# by the mail_owner account (see below).
#
data_directory = /var/lib/postfix
# QUEUE AND PROCESS OWNERSHIP
#
#
mail_owner = postfix
#
#default_privs = nobody
# INTERNET HOST AND DOMAIN NAMES
#
#
#myhostname = host.domain.tld
#myhostname = virtual.domain.tld
#
#mydomain = domain.tld
# SENDING MAIL
#
#myorigin = $myhostname
#myorigin = $mydomain
# RECEIVING MAIL
#inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
inet_interfaces = all
# Enable IPv4, and IPv6 if supported
inet_protocols = all
#
#proxy_interfaces =
#proxy_interfaces = 1.2.3.4
#
mydestination = localhost.$mydomain, localhost, localhost.localdomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
# mail.$mydomain, www.$mydomain, ftp.$mydomain
# REJECTING MAIL FOR UNKNOWN LOCAL USERS
#
#
#local_recipient_maps = unix:passwd.byname $alias_maps
local_recipient_maps = proxy:unix:passwd.byname $alias_maps
#local_recipient_maps =
#
unknown_local_recipient_reject_code = 550
# TRUST AND RELAY CONTROL
#
#mynetworks_style = class
#mynetworks_style = subnet
mynetworks_style = host
#
#mynetworks = 168.100.189.0/28, 127.0.0.0/8
#mynetworks
= $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table
#
#relay_domains = $mydestination
# INTERNET OR INTRANET
#
#relayhost = $mydomain
#relayhost = [gateway.my.domain]
#relayhost = [mailserver.isp.tld]
#relayhost = uucphost
#relayhost = [an.ip.add.ress]
# REJECTING UNKNOWN RELAY USERS
#
#
#relay_recipient_maps = hash:/etc/postfix/relay_recipients
# INPUT RATE CONTROL
#
#
#in_flow_delay = 1s
# ADDRESS REWRITING
#
# The ADDRESS_REWRITING_README document gives information about
# address masquerading or other forms of address rewriting including
# username->Firstname.Lastname mapping.
# ADDRESS REDIRECTION (VIRTUAL DOMAIN)
#
# The VIRTUAL_README document gives information about the many forms
# of domain hosting that Postfix supports.
# "USER HAS MOVED" BOUNCE MESSAGES
#
# See the discussion in the ADDRESS_REWRITING_README document.
# TRANSPORT MAP
#
# See the discussion in the ADDRESS_REWRITING_README document.
# ALIAS DATABASE
#
#
#alias_maps = dbm:/etc/aliases
alias_maps = hash:/etc/aliases, hash:/var/spool/postfix/plesk/aliases
#alias_maps = hash:/etc/aliases, nis:mail.aliases
#alias_maps = netinfo:/aliases
# The alias_database parameter specifies the alias database(s) that
# are built with "newaliases" or "sendmail -bi". This is a separate
# configuration parameter, because alias_maps (see above) may specify
# tables that are not necessarily all under control by Postfix.
#
#alias_database = dbm:/etc/aliases
#alias_database = dbm:/etc/mail/aliases
alias_database = hash:/etc/aliases
#alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
# ADDRESS EXTENSIONS (e.g., user+foo)
#
#
#recipient_delimiter = +
# DELIVERY TO MAILBOX
#
#
#home_mailbox = Mailbox
#home_mailbox = Maildir/
# The mail_spool_directory parameter specifies the directory where
# UNIX-style mailboxes are kept. The default setting depends on the
# system type.
#
#mail_spool_directory = /var/mail
#mail_spool_directory = /var/spool/mail
# The mailbox_command parameter specifies the optional external
# command to use instead of mailbox delivery. The command is run as
# the recipient with proper HOME, SHELL and LOGNAME environment settings.
# Exception: delivery for root is done as $default_user.
#
#
#mailbox_command = /some/where/procmail
#mailbox_command = /some/where/procmail -a "$EXTENSION"
#
#mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
#
# To use the old cyrus deliver program you have to set:
#mailbox_transport = cyrus
#
#fallback_transport = lmtp:unix:/var/lib/imap/socket/lmtp
#fallback_transport =
#luser_relay = $user@other.host
#luser_relay = $local@other.host
#luser_relay = admin+$local
# JUNK MAIL CONTROLS
#
#
#header_checks = regexp:/etc/postfix/header_checks
# FAST ETRN SERVICE
#
#
#fast_flush_domains = $relay_domains
# SHOW SOFTWARE VERSION OR NOT
#
#
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
# PARALLEL DELIVERY TO THE SAME DESTINATION
#
#local_destination_concurrency_limit = 2
#default_destination_concurrency_limit = 20
# DEBUGGING CONTROL
#
#
debug_peer_level = 2
#
#debug_peer_list = 127.0.0.1
#debug_peer_list = some.domain
#
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
#
# debugger_command =
# PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH; screen
# -dmS $process_name gdb $daemon_directory/$process_name
# $process_id & sleep 1
# INSTALL-TIME CONFIGURATION INFORMATION
#
# The following parameters are used when installing a new Postfix version.
#
# sendmail_path: The full pathname of the Postfix sendmail command.
# This is the Sendmail-compatible mail posting interface.
#
sendmail_path = /usr/sbin/sendmail.postfix
# newaliases_path: The full pathname of the Postfix newaliases command.
# This is the Sendmail-compatible command to build alias databases.
#
newaliases_path = /usr/bin/newaliases.postfix
# mailq_path: The full pathname of the Postfix mailq command. This
# is the Sendmail-compatible mail queue listing command.
#
mailq_path = /usr/bin/mailq.postfix
# setgid_group: The group for mail submission and queue management
# commands. This must be a group name with a numerical group ID that
# is not shared with other accounts, not even with the Postfix account.
#
setgid_group = postdrop
# html_directory: The location of the Postfix HTML documentation.
#
html_directory = no
# manpage_directory: The location of the Postfix on-line manual pages.
#
manpage_directory = /usr/share/man
# sample_directory: The location of the Postfix sample configuration files.
# This parameter is obsolete as of Postfix 2.1.
#
sample_directory = /usr/share/doc/postfix-2.8.4/samples
# readme_directory: The location of the Postfix README files.
#
readme_directory = /usr/share/doc/postfix-2.8.4/README_FILES
virtual_mailbox_domains = $virtual_mailbox_maps,
hash:/var/spool/postfix/plesk/virtual_domains
virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual
virtual_mailbox_maps = hash:/var/spool/postfix/plesk/vmailbox
transport_maps = hash:/var/spool/postfix/plesk/transport
smtpd_tls_cert_file = /etc/postfix/postfix_default.pem
smtpd_tls_key_file = $smtpd_tls_cert_file
smtpd_tls_security_level = may
smtpd_use_tls = yes
smtp_tls_security_level = may
smtp_use_tls = no
smtpd_timeout = 3600s
smtpd_proxy_timeout = 3600s
disable_vrfy_command = yes
mynetworks = 127.0.0.0/8, [::1]/128, xxx.xxx.xxx.xxx/32
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks,
reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, permit
smtpd_sender_restrictions = permit_mynetworks,
reject_unknown_sender_domain, reject_unknown_address,
reject_unlisted_sender, reject_non_fqdn_sender,
reject_unknown_sender_domain, permit
# smtpd_client_restrictions = permit_mynetworks, reject_rbl_client
sbl.spamhaus.org
smtp_send_xforward_command = yes
smtpd_authorized_xforward_hosts = 127.0.0.0/8 [::1]/128
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks,
permit_sasl_authenticated, reject_unauth_destination, permit
# smtpd_recipient_restrictions = reject_unauth_pipelining,
reject_non_fqdn_recipient, reject_unknown_recipient_domain,
permit_mynetworks, reject_unauth_destination, check_sender_access
hash:/etc/postfix/sender_access, reject_rbl_client zen.spamhaus.org,
reject_rbl_client bl.spamcop.net, check_policy_service
unix:postgrey/socket, permit
virtual_mailbox_base = /var/qmail/mailnames
virtual_uid_maps = static:110
virtual_gid_maps = static:30
smtpd_milters = inet:localhost:12768
non_smtpd_milters = inet:localhost:12768
sender_dependent_default_transport_maps =
hash:/var/spool/postfix/plesk/sdd_transport_maps
virtual_transport = plesk_virtual
plesk_virtual_destination_recipient_limit = 1
mailman_destination_recipient_limit = 1
myhostname = mail.myinternet.gr
milter_connect_macros = j {daemon_name} v
milter_data_macros = i
milter_end_of_data_macros = i
milter_end_of_header_macros = i
milter_helo_macros = {tls_version} {cipher} {cipher_bits} {cert_subject}
{cert_issuer}
milter_macro_daemon_name = $myhostname
milter_macro_v = $mail_name $mail_version
milter_mail_macros = i {auth_type} {auth_authen} {auth_author} {mail_addr}
milter_rcpt_macros = i {rcpt_addr}
message_size_limit = 40960000
Thank you for your time

Monday, 30 September 2013

If $ a \mid bc $ then $\frac{a}{\gcd(a,b)} \mid c$?

If $ a \mid bc $ then $\frac{a}{\gcd(a,b)} \mid c$?

Prove or reject this statement:
If $ a \mid bc $ then $\displaystyle \frac{a}{\gcd(a,b)} \mid c$

Can a custom module have more than one namespace=?iso-8859-1?Q?=3F_=96_magento.stackexchange.com?=

Can a custom module have more than one namespace? – magento.stackexchange.com

Is it fine to have more than one namespaces for a custom module? I haven't
tried yet. But for some situations it's better if we can have this
feature. Any suggestion will be appreciated. Example: …

Oracle forms migrated from 10g to 11g

Oracle forms migrated from 10g to 11g

Once exported from oracle 10g to 11g, It is saying some java beans are
missing in the form. Is there something we need to change the FORM beans
path in new version.If not, Where are we mentioning the path for java
beans in reports.

Javascript: get *updated* value of textarea

Javascript: get *updated* value of textarea

I have atext area on my page.I am filling it up from some data at page
load.Then user changes the data in textarea and I alert the text of
textarea.but I am getting the same value in alert which was initially
loaded in text area.It's not updating at all.
html:
<textarea rows="8" style="width: 60%" id="cmds"></textarea>
<input type="button" class="btn" value="alert" onclick="alertCmds()" />
javascript"
$.post('/AutoRegress/AutoRegress?cmd=cmdlist'{url:$('#url').val(),revId:$('#revId').val()},
function(data) {
$("#cmds").val(data.replace(/,/g,"\n"));
});
fuction alertCmds(){
alert($('#cmds').text());
}

Sunday, 29 September 2013

Recurrence Relations and drawing Recursion trees

Recurrence Relations and drawing Recursion trees

Here is the algorithm
Algorithm Mystery(A: Array [i..j] of integer) i & j are array starting and
ending indexes
if i=j then return A[i]
else
k=i+floor((j-i)/2)
temp1= Mystery(A[i..k])
temp2= Mystery(A[(k+1)..j]
if temp1<temp2 then return temp1 else return temp2
I believe the complexity is: T(1) = c T(n) = 2T(n/2) + n
but from here I'm not sure where to go all the examples have the second
equation ending with cn so i have no idea how to draw the tree. Did i
solve the recursion wrong? I just need some help getting on the right
direction.

Django REST Framework: object is None only on one attribute, but not other

Django REST Framework: object is None only on one attribute, but not other

I have been having trouble understanding why the object (obj) passed into
field_to_native() changes from Nonetype to a correct object once I change
the attribute...
Here's the original issue: Splitting model instance for serializer into 3
different fields
mariodev from stackoverflow helped me on the original issue, but a strange
bug both of us cannot figure out:
Here's the code where it seems to have the problem:
COORD = dict(x=0, y=1, z=2)
class CoordField(serializers.Field):
def field_to_native(self, obj, field_name):
#retrieve and split coords
coor = obj.xyz.split('x')
return int(coor[COORD[field_name]])
class NoteSerializer(serializers.ModelSerializer):
owner = serializers.Field(source='owner.username')
firstname = serializers.Field(source='owner.first_name')
lastname = serializers.Field(source='owner.last_name')
x = CoordField()
y = CoordField()
z = CoordField()
class Meta:
model = Note
fields =
('id','owner','firstname','lastname','text','color','time','x', 'y',
'z')
xyz is a instance in the model Note. According to the traceback, when I do
obj.xyz, the obj = None.
Weirdly, if I do obj.color, the obj returns correctly (Note: someuser)
I don't understand how the obj can change just by changing the attribute.
What's beyond me is that the JSON data 'x' 'y' and 'z' ARE being passed to
the view, and my div boxes get the correct left, top, and z-index CSS
data. If this works, why am I getting an error?
If there's an error, why is the data still getting through?
style="left: 343px; top: 110px; z-index: 3;"
As you can see, the x,y,z DID pass through.
Any enlightenment would be wonderful! Thanks a bunch!
Here's the traceback in text view:
Traceback: File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/django/core/handlers/base.py"
in get_response 140. response = response.render() File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/django/template/response.py"
in render 105. self.content = self.rendered_content File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/response.py"
in rendered_content 59. ret = renderer.render(self.data, media_type,
context) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/renderers.py"
in render 582. post_form = self.get_rendered_html_form(view, 'POST',
request) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/renderers.py"
in get_rendered_html_form 485. data = serializer.data File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/serializers.py"
in data 510. self._data = self.to_native(obj) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/serializers.py"
in to_native 309. value = field.field_to_native(obj, field_name) File
"/home1/thecupno/django/notes/desk/serializers.py" in field_to_native 10.
coor = obj.xyz#.split('x') <-- I commented out .split, and the problem
still persists.
Exception Type: AttributeError at /desk/restnote/ Exception Value:
'NoneType' object has no attribute 'xyz'

Rails controller action behavior without respond_to

Rails controller action behavior without respond_to

Rails Scaffold generator create some actions in a controller with
respond_to and some without it.
For example:
GET /replaces/new
GET /replaces/new.json
def new
@replace = Replace.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @replace }
end
end
GET /replaces/1/edit
def edit
@replace = Replace.find(params[:id])
end
I understand that Rails renders the view that has the same name as the
action. If I have multiple views with the same name (in different
formats), I have to specify which one you want in the request and use the
respond_to method to respond accordingly.
Questions:
Why the Scaffold generator create some actions without respond_to ?
What will be the behavior if there no respond_to and requests are coming
with different format? HTML? AJAX?

Java Server Faces error when trying to use an if method in my Bean class

Java Server Faces error when trying to use an if method in my Bean class

Hey im trying to set up a voting app that will display whether the user is
able to vote or not using an if statement in my bean class but this Unable
to find matching navigation case with from-view-id '/home.xhtml' for
action '#{user.checkAge(user.age)}' with outcome 'Invalid User, Please Try
Again!!!'. Im not very understanding of Java Server Faces yet and ive
tried messing around with the config files and googling the error but i
cant fix it. Can anyone help me please.
Here is my code:
**
Home.xhtml
**
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<head>
<title>Results Page</title>
</head>
<body>
<h:form>
Name: <h:outputText id="outTxt" value="#{user.name}"/><br></br>
Age: <h:outputText id="outTxt2" value="#{user.age}"/><br></br>
<h:commandButton id="cmdBtn" value="Check"
action="#{user.checkAge(user.age)}"/>
</h:form>
</body>
</html>
**
index.xhtml
**
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Home Page</title>
</h:head>
<h:body>
<h:body>
<h:form>
Name: <h:inputText id="inTxt" value="#{user.name}"/><br></br>
Age: <h:inputText id="inTxt2" value="#{user.age}"/><br></br>
<h:commandButton id="cmdBtn" value="Check" action="home"/>
</h:form>
</h:body>
</h:body>
</html>
**
User.java
**
package MyPackage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class User
{
private String name;
private int age;
private String msg;
public String getMsg()
{
return msg;
}
public void setMsg(String msg)
{
this.msg = msg;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
public String checkAge(int checkAgeVoter)
{
if(checkAgeVoter >= 18)
{
msg = "Valid User, Access Granted!!!";
}
else
{
msg = "Invalid User, Please Try Again!!!";
}
return msg;
}
}

Saturday, 28 September 2013

Only Print DataGridView in windows forms

Only Print DataGridView in windows forms

i want to ask, how do i print only DataGridView in windows forms and using
my own format. I also didn't know how to print a file in windows forms.
Could you guys help me? This will be my format when print:

And here is my DataGridView:

NOTE: This is just an example (only the DataGridView, but for the format i
want to when print be like that.

My background isn't spanning horizontally

My background isn't spanning horizontally

I have this code, the only code on the site that would be affecting the
background. I had Eric Meyer's CSS reset on, but commented it out to see.
It made no difference. The only code I have left is this.
* {
margin: 0;
padding: 0;
}
body {
background: url("../images/bg.png") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I tried many different things to get it to touch the side of the browsers,
but there remains an annoying margin or something on the sides. Any ideas
on how to get rid of this?
Here's what it looks like:

How to close previous popovers in fullCalendar?

How to close previous popovers in fullCalendar?

I am using fullCalendar in my website together with Bootstrap so that
everytime I click on a day in month view, there is a popover to add event,
just like that in Google Calendar. Here is my code
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
height: height,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
dayClick: function( date, allDay, jsEvent, view ){
$(this).children().popover({
title: 'haha',
placement: 'right',
content: 'haha',html : true, container: 'body'
});
$(this).children().popover('show');
}
})
The code should be right before $(this).children().popover({ so that it
closes all previously fired popover.
However, exactly, what code should I use to achieve this?
Thank you!